11 lines
13 KiB
JavaScript
Raw Normal View History

module.exports=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},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=5)}([function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat["components/TextEditor"]},function(t,e){t.exports=flarum.core.compat.Component},function(t,e,n){var i,r,l;"undefined"!=typeof self&&self,r=[],void 0===(l="function"==typeof(i=function(){var t=/mac|iphone|ipad|ipod/i.test(navigator.platform)?"metaKey":"ctrlKey",e=/[*_]/,n=/^[ \t]*(?:(?:[-+*]|\d+\.)[ \t]+(?:\[[ x]][ \t]+)?|>[ \t]*)*(?::[ \t]*)?/,i=/[-=\s"'`<>\[\](){}+*^$\\.|]$/,r=/(?:[-+*]|\d+\.)[ \t]+(?:\[[ x]][ \t]+)?$/,l=/^(?:\n|$)/,o=/[-+*\[\]x\d.]/g,s=/[^ \t]/g,a=/(\d+)\.(?=[ \t]+$)/,c=/(?:(?:^[ \t]+)?(?:[-+*]|\d+\.|[>:])(?:[ \t]+\[[ x]])?[ \t]*|^[ \t]+)$/,u=/^(?!$)/gm,f={"`":/^``$/m,"~":/^~~$/m},h={"[":"]","(":")","{":"}","<":">"},d={"]":"[",")":"(","}":"{",">":"<"},p={enter:["Enter","Shift+Enter"],indent:["Tab","Cmd+m"],outdent:["Shift+Tab","Cmd+Shift+m"],inline:['"',"'","`","*","_","[","]","(",")","{","}","<",">"]};function m(t,e){var n,i;this._options=((n=e)||(n={}),n.keyMap=function(t){t||(t={});var e={},n=[];for(var i in p)if(p.hasOwnProperty(i)){var r=t[i]||p[i];Array.isArray(r)||(r=r.toString().trim().split(/\s*[|,]\s*/g)),n.push.apply(n,r.map((function(t){return(t=v(t)).key in e||(e[t.key]=0),++e[t.key],{key:t,action:i}})))}return n.forEach((function(t){var n;1<e[t.key.key]&&("ctrlKey"in(n=t.key)||(n.ctrlKey=!1),"altKey"in n||(n.altKey=!1),"shiftKey"in n||(n.shiftKey=!1),"metaKey"in n||(n.metaKey=!1))})),n}(n.keyMap),n.indent=("number"!=typeof(i=n.indent||4)&&(i=(i+"").length),new Array(i+1).join(" ")),n),this._reOutdent=new RegExp("^"+this._options.indent,"mg"),this._handleKey=this._handleKey.bind(this),this.setElement(t)}function v(e){var n={};return e.trim().split(/\s*\+\s*/g).forEach((function(e){switch(e.toLowerCase()){case"cmd":n[t]=!0;break;case"ctrl":case"alt":case"shift":case"meta":n[e.toLowerCase()+"Key"]=!0;break;default:n.key=e}})),n}function y(t,e,n,i){if(t.value=e,t.selectionStart=n,t.selectionEnd=3<arguments.length?i:n,"InputEvent"in window)try{var r=new InputEvent("input");t.dispatchEvent(r)}catch(i){}}function g(t,e){return t.replace(e?s:o," ")}return m.prototype={constructor:m,getElement:function(){return this._elem},setElement:function(t){this._elem&&this._elem.removeEventListener("keydown",this._handleKey),(this._elem=t).addEventListener("keydown",this._handleKey)},getValue:function(){return this._elem.value},setValue:function(t){this._elem.value=t},destroy:function(){this._elem.removeEventListener("keydown",this._handleKey),this._elem=this._options=this._reOutdent=this._handleKey=null},_handleKey:function(t){if(!t.defaultPrevented){var o=this._options.keyMap.find((function(e){return function(t,e){for(var n in e)if(e.hasOwnProperty(n)&&t[n]!==e[n])return!1;return!0}(t,e.key)}));if(o){var s=this._elem.value.substring(0,this._elem.selectionStart),p=this._elem.value.substring(this._elem.selectionStart,this._elem.selectionEnd),m=this._elem.value.substring(this._elem.selectionEnd);switch(o.action){case"enter":!function(t,e,i,o,s,u){var f,d,p,m,v,x=i?null:(d=(f=e).lastIndexOf("\n")+1,{line:p=f.substring(d),offset:d,prefix:(m=n.exec(p))&&m[0]});if(i)e+="\n";else if(x.line&&x.line.charAt(x
/*!
* Includes modified code from GitHub Markdown Toolbar Element
* https://github.com/github/markdown-toolbar-element/
*
* Original Copyright GitHub, Inc.
* Released under the MIT license
* https://github.com/github/markdown-toolbar-element/blob/master/LICENSE
*/
app.initializers.add("flarum-markdown",(function(t){var e=1;Object(i.extend)(l.a.prototype,"oninit",(function(){this.textareaId="textarea"+e++})),Object(i.extend)(l.a.prototype,"view",(function(t){t.children[0].attrs.id=this.textareaId})),Object(i.extend)(l.a.prototype,"oncreate",(function(){this.editor=new s.a(this.$("textarea")[0],{keyMap:{indent:["Ctrl+m"],outdent:["Ctrl+M"],inline:[]}})})),Object(i.extend)(l.a.prototype,"onremove",(function(){this.editor.destroy()})),Object(i.extend)(l.a.prototype,"toolbarItems",(function(e){var n=function(e){return t.translator.trans("flarum-markdown.forum.composer."+e+"_tooltip")};e.add("markdown",m(h,{for:this.textareaId},m(O,{title:n("header"),icon:"fas fa-heading",style:{prefix:"### "}}),m(O,{title:n("bold"),icon:"fas fa-bold",style:{prefix:"**",suffix:"**",trimFirst:!0},hotkey:"b"}),m(O,{title:n("italic"),icon:"fas fa-italic",style:{prefix:"_",suffix:"_",trimFirst:!0},hotkey:"i"}),m(O,{title:n("quote"),icon:"fas fa-quote-left",style:{prefix:"> ",multiline:!0,surroundWithNewlines:!0}}),m(O,{title:n("code"),icon:"fas fa-code",style:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"}}),m(O,{title:n("link"),icon:"fas fa-link",style:{prefix:"[",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"}}),m(O,{title:n("image"),icon:"fas fa-image",style:{prefix:"![",suffix:"](https://)",replaceNext:"https://",scanFor:"https?://"}}),m(O,{title:n("unordered_list"),icon:"fas fa-list-ul",style:{prefix:"- ",multiline:!0,surroundWithNewlines:!0}}),m(O,{title:n("ordered_list"),icon:"fas fa-list-ol",style:{prefix:"1. ",multiline:!0,orderedList:!0}})),100)}))}))}]);
//# sourceMappingURL=forum.js.map