mirror of
https://github.com/flarum/framework.git
synced 2025-03-02 20:14:25 +08:00
2 lines
32 KiB
JavaScript
2 lines
32 KiB
JavaScript
module.exports=function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.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 i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));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=5)}([function(t,e){t.exports=flarum.core.compat["helpers/icon"]},function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat["components/TextEditor"]},function(t,e,n){var o,i,r;"undefined"!=typeof self&&self,i=[],void 0===(r="function"==typeof(o=function(){var t=/mac|iphone|ipad|ipod/i.test(navigator.platform)?"metaKey":"ctrlKey",e=/^["'`*_[({<>})\]]$/,n=/[*_]/,o=/^[ \t]*(?:(?:[-+*]|\d+\.)[ \t]+(?:\[[ x]][ \t]+)?|>[ \t]*)*(?::[ \t]*)?/,i=/(?:[-+*]|\d+\.)[ \t]+(?:\[[ x]][ \t]+)?$/,r=/[-+*\[\]x\d.]/g,l=/[^ \t]/g,a=/(\d+)\.(?=[ \t]+$)/,s=/(?:(?:^[ \t]+)?(?:[-+*]|\d+\.|[>:])(?:[ \t]+\[[ x]])?[ \t]*|^[ \t]+)$/,c=/^(?!$)/gm,u={"`":/^``$/m,"~":/^~~$/m},f={"[":"]","(":")","{":"}","<":">"},d={"]":"[",")":"(","}":"{",">":"<"};function h(t){this._useTab=!0,this._useInline=!0,this._indent=" ",this._reOutdent=/^[ ]{4}/gm,this._reKey=p(!0,!0),this._handleKey=this._handleKey.bind(this),this.setElement(t)}function p(t,e){return new RegExp("^(?:Enter"+(t?"|Tab":"")+"|[io"+(e?"\"'`*_([{<>}\\])":"")+"])$")}function m(t,e,n,o){if(t.value=e,t.selectionStart=n,t.selectionEnd=arguments.length>3?o:n,"InputEvent"in window)try{var i=new InputEvent("input");t.dispatchEvent(i)}catch(o){}}return h.prototype={constructor:h,getElement:function(){return this._elem},setElement:function(t){this._elem&&this._elem.removeEventListener("keydown",this._handleKey),this._elem=t,t.addEventListener("keydown",this._handleKey)},getValue:function(){return this._elem.value},setValue:function(t){this._elem.value=t},getIndent:function(){return this._indent},setIndent:function(t){this._indent="number"==typeof t?new Array(t+1).join(" "):(t+"").replace(/[^ \t]/g," "),this._reOutdent=new RegExp("^"+this._indent,"mg")},isTabUsed:function(){return this._useTab},useTab:function(){this._useTab=!0,this._reKey=p(!0,this._useInline)},ignoreTab:function(){this._useTab=!1,this._reKey=p(!1,this._useInline)},isInlineEnabled:function(){return this._useInline},enableInline:function(){this._useInline=!0,this._reKey=p(this._useTab,!0)},disableInline:function(){this._useInline=!1,this._reKey=p(this._useTab,!1)},destroy:function(){this._elem.removeEventListener("keydown",this._handleKey),this._elem=this._reKey=this._handleKey=this._indent=this._reOutdent=null},_handleKey:function(h){if(!h.defaultPrevented&&this._reKey.test(h.key)){var p=h.target.value.substring(0,h.target.selectionStart),v=h.target.value.substring(h.target.selectionStart,h.target.selectionEnd),g=h.target.value.substring(h.target.selectionEnd);if("Enter"!==h.key||h.ctrlKey||h.altKey||h.metaKey)if("Tab"===h.key&&!h.shiftKey||"i"===h.key&&h[t])!function(t,e,n,o,i){var r=e.length,l=e.lastIndexOf("\n")+1;l<r&&(n=e.substring(l)+n,e=e.substring(0,l)),(l<r||!n)&&(r+=i.length),n?n=n.replace(c,i):e+=i,m(t,e+n+o,r,n?l+n.length:r)}(this._elem,p,v,g,this._indent);else if("Tab"===h.key&&h.shiftKey||"o"===h.key&&h[t])!function(t,e,n,o,i,r){var l=e.length,a=e.lastIndexOf("\n")+1;a<l&&(n=e.substring(a)+n,e=e.substring(0,a),n.substring(0,i.length)===i&&(l-=i.length)),n=n.replace(r,""),m(t,e+n+o,l,a+n.length)}(this._elem,p,v,g,this._indent,this._reOutdent);else{if(!e.test(h.key))return;!function(t,e,o,i,r){o||r in f||i.charAt(0)!==r?!o&&("'"===r||r in d)?m(t,e+r+i,e.length+1):!o&&r in u&&u[r].test(e)?m(t,e+r+"language\n"+r+r+r+("\n"!==i.charAt(0)?"\n":"")+i,e.length+1,e.length+9):m(t,e+(d[r]||r)+o+(f[r]||r)+i,e.length+1,e.length+1+o.length):m(t,e+(n.test(r)?r+r:"")+i,e.length+1)}(this._elem,p,v,g,h.key)}else!function(t,e,n,c,u){var f,d,h,p,v=n?null:(d=(f=e).lastIndexOf("\n")+1,h=f.substring(d),p=o.exec(h),{line:h,offset:d,prefix:p&&p[0]});!n&&v.prefix?u||v.prefix!==v.line?!u&&function(t){return i.test(t)}(v.prefix)?e+="\n"+function(t){return t.replace(a,function(t,e){return parseInt(e)+1+"."})}(v.prefix):e+="\n"+function(t,e){return t.replace(e?l:r," ")}(v.prefix,u):e=e.substring(0,v.offset)+function(t){return t.replace(s,"")}(v.prefix):e+="\n",m(t,e+c,e.length)}(this._elem,p,v,g,h.shiftKey);h.preventDefault()}}},h})?o.apply(e,i):o)||(t.exports=r)},function(t,e){(function(){"use strict";var t=new Set("annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" "));function e(e){var n=t.has(e);return e=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(e),!n&&e}function n(t){var e=t.isConnected;if(void 0!==e)return e;for(;t&&!(t.__CE_isImportDocument||t instanceof Document);)t=t.parentNode||(window.ShadowRoot&&t instanceof ShadowRoot?t.host:void 0);return!(!t||!(t.__CE_isImportDocument||t instanceof Document))}function o(t,e){for(;e&&e!==t&&!e.nextSibling;)e=e.parentNode;return e&&e!==t?e.nextSibling:null}function i(t,e,n){n=void 0===n?new Set:n;for(var r=t;r;){if(r.nodeType===Node.ELEMENT_NODE){var l=r;e(l);var a=l.localName;if("link"===a&&"import"===l.getAttribute("rel")){if((r=l.import)instanceof Node&&!n.has(r))for(n.add(r),r=r.firstChild;r;r=r.nextSibling)i(r,e,n);r=o(t,l);continue}if("template"===a){r=o(t,l);continue}if(l=l.__CE_shadowRoot)for(l=l.firstChild;l;l=l.nextSibling)i(l,e,n)}r=r.firstChild?r.firstChild:o(t,r)}}function r(t,e,n){t[e]=n}function l(){this.a=new Map,this.f=new Map,this.c=[],this.b=!1}function a(t,e){t.b=!0,t.c.push(e)}function s(t,e){t.b&&i(e,function(e){return c(t,e)})}function c(t,e){if(t.b&&!e.__CE_patched){e.__CE_patched=!0;for(var n=0;n<t.c.length;n++)t.c[n](e)}}function u(t,e){var n=[];for(i(e,function(t){return n.push(t)}),e=0;e<n.length;e++){var o=n[e];1===o.__CE_state?t.connectedCallback(o):h(t,o)}}function f(t,e){var n=[];for(i(e,function(t){return n.push(t)}),e=0;e<n.length;e++){var o=n[e];1===o.__CE_state&&t.disconnectedCallback(o)}}function d(t,e,n){var o=(n=void 0===n?{}:n).u||new Set,r=n.h||function(e){return h(t,e)},l=[];if(i(e,function(e){if("link"===e.localName&&"import"===e.getAttribute("rel")){var n=e.import;n instanceof Node&&(n.__CE_isImportDocument=!0,n.__CE_hasRegistry=!0),n&&"complete"===n.readyState?n.__CE_documentLoadHandled=!0:e.addEventListener("load",function(){var n=e.import;if(!n.__CE_documentLoadHandled){n.__CE_documentLoadHandled=!0;var i=new Set(o);i.delete(n),d(t,n,{u:i,h:r})}})}else l.push(e)},o),t.b)for(e=0;e<l.length;e++)c(t,l[e]);for(e=0;e<l.length;e++)r(l[e])}function h(t,e){if(void 0===e.__CE_state){var o=e.ownerDocument;if((o.defaultView||o.__CE_isImportDocument&&o.__CE_hasRegistry)&&(o=t.a.get(e.localName))){o.constructionStack.push(e);var i=o.constructorFunction;try{try{if(new i!==e)throw Error("The custom element constructor did not produce the element being upgraded.")}finally{o.constructionStack.pop()}}catch(t){throw e.__CE_state=2,t}if(e.__CE_state=1,e.__CE_definition=o,o.attributeChangedCallback)for(o=o.observedAttributes,i=0;i<o.length;i++){var r=o[i],l=e.getAttribute(r);null!==l&&t.attributeChangedCallback(e,r,null,l,null)}n(e)&&t.connectedCallback(e)}}}function p(t){var e=document;this.c=t,this.a=e,this.b=void 0,d(this.c,this.a),"loading"===this.a.readyState&&(this.b=new MutationObserver(this.f.bind(this)),this.b.observe(this.a,{childList:!0,subtree:!0}))}function m(t){t.b&&t.b.disconnect()}function v(){var t=this;this.b=this.a=void 0,this.c=new Promise(function(e){t.b=e,t.a&&e(t.a)})}function g(t){if(t.a)throw Error("Already resolved.");t.a=void 0,t.b&&t.b(void 0)}function y(t){this.c=!1,this.a=t,this.j=new Map,this.f=function(t){return t()},this.b=!1,this.i=[],this.o=new p(t)}l.prototype.connectedCallback=function(t){var e=t.__CE_definition;e.connectedCallback&&e.connectedCallback.call(t)},l.prototype.disconnectedCallback=function(t){var e=t.__CE_definition;e.disconnectedCallback&&e.disconnectedCallback.call(t)},l.prototype.attributeChangedCallback=function(t,e,n,o,i){var r=t.__CE_definition;r.attributeChangedCallback&&-1<r.observedAttributes.indexOf(e)&&r.attributeChangedCallback.call(t,e,n,o,i)},p.prototype.f=function(t){var e=this.a.readyState;for("interactive"!==e&&"complete"!==e||m(this),e=0;e<t.length;e++)for(var n=t[e].addedNodes,o=0;o<n.length;o++)d(this.c,n[o])},y.prototype.l=function(t,n){var o=this;if(!(n instanceof Function))throw new TypeError("Custom element constructors must be functions.");if(!e(t))throw new SyntaxError("The element name '"+t+"' is not valid.");if(this.a.a.get(t))throw Error("A custom element with name '"+t+"' has already been defined.");if(this.c)throw Error("A custom element is already being defined.");this.c=!0;try{var i=function(t){var e=r[t];if(void 0!==e&&!(e instanceof Function))throw Error("The '"+t+"' callback must be a function.");return e},r=n.prototype;if(!(r instanceof Object))throw new TypeError("The custom element constructor's prototype is not an object.");var l=i("connectedCallback"),a=i("disconnectedCallback"),s=i("adoptedCallback"),c=i("attributeChangedCallback"),u=n.observedAttributes||[]}catch(t){return}finally{this.c=!1}n={localName:t,constructorFunction:n,connectedCallback:l,disconnectedCallback:a,adoptedCallback:s,attributeChangedCallback:c,observedAttributes:u,constructionStack:[]},function(t,e,n){t.a.set(e,n),t.f.set(n.constructorFunction,n)}(this.a,t,n),this.i.push(n),this.b||(this.b=!0,this.f(function(){return function(t){if(!1!==t.b){t.b=!1;for(var e=t.i,n=[],o=new Map,i=0;i<e.length;i++)o.set(e[i].localName,[]);for(d(t.a,document,{h:function(e){if(void 0===e.__CE_state){var i=e.localName,r=o.get(i);r?r.push(e):t.a.a.get(i)&&n.push(e)}}}),i=0;i<n.length;i++)h(t.a,n[i]);for(;0<e.length;){var r=e.shift();i=r.localName,r=o.get(r.localName);for(var l=0;l<r.length;l++)h(t.a,r[l]);(i=t.j.get(i))&&g(i)}}}(o)}))},y.prototype.h=function(t){d(this.a,t)},y.prototype.get=function(t){if(t=this.a.a.get(t))return t.constructorFunction},y.prototype.m=function(t){if(!e(t))return Promise.reject(new SyntaxError("'"+t+"' is not a valid custom element name."));var n=this.j.get(t);return n?n.c:(n=new v,this.j.set(t,n),this.a.a.get(t)&&!this.i.some(function(e){return e.localName===t})&&g(n),n.c)},y.prototype.s=function(t){m(this.o);var e=this.f;this.f=function(n){return t(function(){return e(n)})}},window.CustomElementRegistry=y,y.prototype.define=y.prototype.l,y.prototype.upgrade=y.prototype.h,y.prototype.get=y.prototype.get,y.prototype.whenDefined=y.prototype.m,y.prototype.polyfillWrapFlushCallback=y.prototype.s;var w=window.Document.prototype.createElement,b=window.Document.prototype.createElementNS,_=window.Document.prototype.importNode,E=window.Document.prototype.prepend,C=window.Document.prototype.append,k=window.DocumentFragment.prototype.prepend,x=window.DocumentFragment.prototype.append,O=window.Node.prototype.cloneNode,S=window.Node.prototype.appendChild,j=window.Node.prototype.insertBefore,N=window.Node.prototype.removeChild,T=window.Node.prototype.replaceChild,M=Object.getOwnPropertyDescriptor(window.Node.prototype,"textContent"),A=window.Element.prototype.attachShadow,P=Object.getOwnPropertyDescriptor(window.Element.prototype,"innerHTML"),L=window.Element.prototype.getAttribute,D=window.Element.prototype.setAttribute,I=window.Element.prototype.removeAttribute,F=window.Element.prototype.getAttributeNS,H=window.Element.prototype.setAttributeNS,K=window.Element.prototype.removeAttributeNS,R=window.Element.prototype.insertAdjacentElement,B=window.Element.prototype.insertAdjacentHTML,W=window.Element.prototype.prepend,$=window.Element.prototype.append,U=window.Element.prototype.before,q=window.Element.prototype.after,z=window.Element.prototype.replaceWith,V=window.Element.prototype.remove,Q=window.HTMLElement,X=Object.getOwnPropertyDescriptor(window.HTMLElement.prototype,"innerHTML"),G=window.HTMLElement.prototype.insertAdjacentElement,J=window.HTMLElement.prototype.insertAdjacentHTML,Y=new function(){};function Z(t,e,o){function i(e){return function(o){for(var i=[],r=0;r<arguments.length;++r)i[r]=arguments[r];r=[];for(var l=[],a=0;a<i.length;a++){var s=i[a];if(s instanceof Element&&n(s)&&l.push(s),s instanceof DocumentFragment)for(s=s.firstChild;s;s=s.nextSibling)r.push(s);else r.push(s)}for(e.apply(this,i),i=0;i<l.length;i++)f(t,l[i]);if(n(this))for(i=0;i<r.length;i++)(l=r[i])instanceof Element&&u(t,l)}}void 0!==o.g&&(e.prepend=i(o.g)),void 0!==o.append&&(e.append=i(o.append))}var tt,et=window.customElements;if(!et||et.forcePolyfill||"function"!=typeof et.define||"function"!=typeof et.get){var nt=new l;tt=nt,window.HTMLElement=function(){function t(){var t=this.constructor,e=tt.f.get(t);if(!e)throw Error("The custom element being constructed was not registered with `customElements`.");var n=e.constructionStack;if(0===n.length)return n=w.call(document,e.localName),Object.setPrototypeOf(n,t.prototype),n.__CE_state=1,n.__CE_definition=e,c(tt,n),n;var o=n[e=n.length-1];if(o===Y)throw Error("The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.");return n[e]=Y,Object.setPrototypeOf(o,t.prototype),c(tt,o),o}return t.prototype=Q.prototype,Object.defineProperty(t.prototype,"constructor",{writable:!0,configurable:!0,enumerable:!1,value:t}),t}(),function(){var t=nt;r(Document.prototype,"createElement",function(e){if(this.__CE_hasRegistry){var n=t.a.get(e);if(n)return new n.constructorFunction}return e=w.call(this,e),c(t,e),e}),r(Document.prototype,"importNode",function(e,n){return e=_.call(this,e,!!n),this.__CE_hasRegistry?d(t,e):s(t,e),e}),r(Document.prototype,"createElementNS",function(e,n){if(this.__CE_hasRegistry&&(null===e||"http://www.w3.org/1999/xhtml"===e)){var o=t.a.get(n);if(o)return new o.constructorFunction}return e=b.call(this,e,n),c(t,e),e}),Z(t,Document.prototype,{g:E,append:C})}(),Z(nt,DocumentFragment.prototype,{g:k,append:x}),function(){function t(t,o){Object.defineProperty(t,"textContent",{enumerable:o.enumerable,configurable:!0,get:o.get,set:function(t){if(this.nodeType===Node.TEXT_NODE)o.set.call(this,t);else{var i=void 0;if(this.firstChild){var r=this.childNodes,l=r.length;if(0<l&&n(this)){i=Array(l);for(var a=0;a<l;a++)i[a]=r[a]}}if(o.set.call(this,t),i)for(t=0;t<i.length;t++)f(e,i[t])}}})}var e=nt;r(Node.prototype,"insertBefore",function(t,o){if(t instanceof DocumentFragment){var i=Array.prototype.slice.apply(t.childNodes);if(t=j.call(this,t,o),n(this))for(o=0;o<i.length;o++)u(e,i[o]);return t}return i=n(t),o=j.call(this,t,o),i&&f(e,t),n(this)&&u(e,t),o}),r(Node.prototype,"appendChild",function(t){if(t instanceof DocumentFragment){var o=Array.prototype.slice.apply(t.childNodes);if(t=S.call(this,t),n(this))for(var i=0;i<o.length;i++)u(e,o[i]);return t}return o=n(t),i=S.call(this,t),o&&f(e,t),n(this)&&u(e,t),i}),r(Node.prototype,"cloneNode",function(t){return t=O.call(this,!!t),this.ownerDocument.__CE_hasRegistry?d(e,t):s(e,t),t}),r(Node.prototype,"removeChild",function(t){var o=n(t),i=N.call(this,t);return o&&f(e,t),i}),r(Node.prototype,"replaceChild",function(t,o){if(t instanceof DocumentFragment){var i=Array.prototype.slice.apply(t.childNodes);if(t=T.call(this,t,o),n(this))for(f(e,o),o=0;o<i.length;o++)u(e,i[o]);return t}i=n(t);var r=T.call(this,t,o),l=n(this);return l&&f(e,o),i&&f(e,t),l&&u(e,t),r}),M&&M.get?t(Node.prototype,M):a(e,function(e){t(e,{enumerable:!0,configurable:!0,get:function(){for(var t=[],e=0;e<this.childNodes.length;e++)t.push(this.childNodes[e].textContent);return t.join("")},set:function(t){for(;this.firstChild;)N.call(this,this.firstChild);S.call(this,document.createTextNode(t))}})})}(),function(){function t(t,e){Object.defineProperty(t,"innerHTML",{enumerable:e.enumerable,configurable:!0,get:e.get,set:function(t){var o=this,r=void 0;if(n(this)&&(r=[],i(this,function(t){t!==o&&r.push(t)})),e.set.call(this,t),r)for(var a=0;a<r.length;a++){var c=r[a];1===c.__CE_state&&l.disconnectedCallback(c)}return this.ownerDocument.__CE_hasRegistry?d(l,this):s(l,this),t}})}function e(t,e){r(t,"insertAdjacentElement",function(t,o){var i=n(o);return t=e.call(this,t,o),i&&f(l,o),n(t)&&u(l,o),t})}function o(t,e){function n(t,e){for(var n=[];t!==e;t=t.nextSibling)n.push(t);for(e=0;e<n.length;e++)d(l,n[e])}r(t,"insertAdjacentHTML",function(t,o){if("beforebegin"===(t=t.toLowerCase())){var i=this.previousSibling;e.call(this,t,o),n(i||this.parentNode.firstChild,this)}else if("afterbegin"===t)i=this.firstChild,e.call(this,t,o),n(this.firstChild,i);else if("beforeend"===t)i=this.lastChild,e.call(this,t,o),n(i||this.firstChild,null);else{if("afterend"!==t)throw new SyntaxError("The value provided ("+String(t)+") is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'.");i=this.nextSibling,e.call(this,t,o),n(this.nextSibling,i)}})}var l=nt;A&&r(Element.prototype,"attachShadow",function(t){return this.__CE_shadowRoot=A.call(this,t)}),P&&P.get?t(Element.prototype,P):X&&X.get?t(HTMLElement.prototype,X):a(l,function(e){t(e,{enumerable:!0,configurable:!0,get:function(){return O.call(this,!0).innerHTML},set:function(t){var e="template"===this.localName,n=e?this.content:this,o=b.call(document,this.namespaceURI,this.localName);for(o.innerHTML=t;0<n.childNodes.length;)N.call(n,n.childNodes[0]);for(t=e?o.content:o;0<t.childNodes.length;)S.call(n,t.childNodes[0])}})}),r(Element.prototype,"setAttribute",function(t,e){if(1!==this.__CE_state)return D.call(this,t,e);var n=L.call(this,t);D.call(this,t,e),e=L.call(this,t),l.attributeChangedCallback(this,t,n,e,null)}),r(Element.prototype,"setAttributeNS",function(t,e,n){if(1!==this.__CE_state)return H.call(this,t,e,n);var o=F.call(this,t,e);H.call(this,t,e,n),n=F.call(this,t,e),l.attributeChangedCallback(this,e,o,n,t)}),r(Element.prototype,"removeAttribute",function(t){if(1!==this.__CE_state)return I.call(this,t);var e=L.call(this,t);I.call(this,t),null!==e&&l.attributeChangedCallback(this,t,e,null,null)}),r(Element.prototype,"removeAttributeNS",function(t,e){if(1!==this.__CE_state)return K.call(this,t,e);var n=F.call(this,t,e);K.call(this,t,e);var o=F.call(this,t,e);n!==o&&l.attributeChangedCallback(this,e,n,o,t)}),G?e(HTMLElement.prototype,G):R?e(Element.prototype,R):console.warn("Custom Elements: `Element#insertAdjacentElement` was not patched."),J?o(HTMLElement.prototype,J):B?o(Element.prototype,B):console.warn("Custom Elements: `Element#insertAdjacentHTML` was not patched."),Z(l,Element.prototype,{g:W,append:$}),function(t){function e(e){return function(o){for(var i=[],r=0;r<arguments.length;++r)i[r]=arguments[r];r=[];for(var l=[],a=0;a<i.length;a++){var s=i[a];if(s instanceof Element&&n(s)&&l.push(s),s instanceof DocumentFragment)for(s=s.firstChild;s;s=s.nextSibling)r.push(s);else r.push(s)}for(e.apply(this,i),i=0;i<l.length;i++)f(t,l[i]);if(n(this))for(i=0;i<r.length;i++)(l=r[i])instanceof Element&&u(t,l)}}var o=Element.prototype;void 0!==U&&(o.before=e(U)),void 0!==U&&(o.after=e(q)),void 0!==z&&r(o,"replaceWith",function(e){for(var o=[],i=0;i<arguments.length;++i)o[i]=arguments[i];i=[];for(var r=[],l=0;l<o.length;l++){var a=o[l];if(a instanceof Element&&n(a)&&r.push(a),a instanceof DocumentFragment)for(a=a.firstChild;a;a=a.nextSibling)i.push(a);else i.push(a)}for(l=n(this),z.apply(this,o),o=0;o<r.length;o++)f(t,r[o]);if(l)for(f(t,this),o=0;o<i.length;o++)(r=i[o])instanceof Element&&u(t,r)}),void 0!==V&&r(o,"remove",function(){var e=n(this);V.call(this),e&&f(t,this)})}(l)}(),document.__CE_hasRegistry=!0;var ot=new y(nt);Object.defineProperty(window,"customElements",{configurable:!0,enumerable:!0,value:ot})}}).call(self)},function(t,e,n){"use strict";function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}n.r(e);var i=n(1),r=n(2),l=n.n(r),a=n(0),s=n.n(a),c=(n(4),Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}),u=function t(e,n,o){null===e&&(e=Function.prototype);var i=Object.getOwnPropertyDescriptor(e,n);if(void 0===i){var r=Object.getPrototypeOf(e);return null===r?void 0:t(r,n,o)}if("value"in i)return i.value;var l=i.get;return void 0!==l?l.call(o):void 0},f=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}();function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function v(){return Reflect.construct(HTMLElement,[],this.__proto__.constructor)}Object.setPrototypeOf(v.prototype,HTMLElement.prototype),Object.setPrototypeOf(v,HTMLElement);var g=new WeakMap,y=function(t){function e(){d(this,e);var t,n=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this)),o=function(){var t=g.get(n);t&&H(n,t)};return n.addEventListener("keydown",(t=o,function(e){" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),t(e))})),n.addEventListener("click",o),n}return p(e,v),f(e,[{key:"connectedCallback",value:function(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.hasAttribute("role")||this.setAttribute("role","button")}},{key:"click",value:function(){var t=g.get(this);t&&H(this,t)}}]),e}(),w=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"### "}),t}return p(e,y),e}();window.customElements.get("md-header")||(window.MarkdownHeaderButtonElement=w,window.customElements.define("md-header",w));var b=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"**",suffix:"**",trimFirst:!0}),t}return p(e,y),f(e,[{key:"connectedCallback",value:function(){u(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"connectedCallback",this).call(this),this.setAttribute("hotkey","b")}}]),e}();window.customElements.get("md-bold")||(window.MarkdownBoldButtonElement=b,window.customElements.define("md-bold",b));var _=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"_",suffix:"_",trimFirst:!0}),t}return p(e,y),f(e,[{key:"connectedCallback",value:function(){u(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"connectedCallback",this).call(this),this.setAttribute("hotkey","i")}}]),e}();window.customElements.get("md-italic")||(window.MarkdownItalicButtonElement=_,window.customElements.define("md-italic",_));var E=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"> ",multiline:!0,surroundWithNewlines:!0}),t}return p(e,y),e}();window.customElements.get("md-quote")||(window.MarkdownQuoteButtonElement=E,window.customElements.define("md-quote",E));var C=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"}),t}return p(e,y),e}();window.customElements.get("md-code")||(window.MarkdownCodeButtonElement=C,window.customElements.define("md-code",C));var k=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"}),t}return p(e,y),f(e,[{key:"connectedCallback",value:function(){u(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"connectedCallback",this).call(this),this.setAttribute("hotkey","k")}}]),e}();window.customElements.get("md-link")||(window.MarkdownLinkButtonElement=k,window.customElements.define("md-link",k));var x=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"- ",multiline:!0,surroundWithNewlines:!0}),t}return p(e,y),e}();window.customElements.get("md-unordered-list")||(window.MarkdownUnorderedListButtonElement=x,window.customElements.define("md-unordered-list",x));var O=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"1. ",multiline:!0,orderedList:!0}),t}return p(e,y),e}();window.customElements.get("md-ordered-list")||(window.MarkdownOrderedListButtonElement=O,window.customElements.define("md-ordered-list",O));var S=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0}),t}return p(e,y),f(e,[{key:"connectedCallback",value:function(){u(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"connectedCallback",this).call(this),this.setAttribute("hotkey","L")}}]),e}();window.customElements.get("md-task-list")||(window.MarkdownTaskListButtonElement=S,window.customElements.define("md-task-list",S));var j=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"@",prefixSpace:!0}),t}return p(e,y),e}();window.customElements.get("md-mention")||(window.MarkdownMentionButtonElement=j,window.customElements.define("md-mention",j));var N=function(t){function e(){d(this,e);var t=h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return g.set(t,{prefix:"#",prefixSpace:!0}),t}return p(e,y),e}();window.customElements.get("md-ref")||(window.MarkdownRefButtonElement=N,window.customElements.define("md-ref",N));var T=navigator.userAgent.match(/Macintosh/)?"Meta":"Control",M=function(t){function e(){return d(this,e),h(this,(e.__proto__||Object.getPrototypeOf(e)).call(this))}return p(e,v),f(e,[{key:"connectedCallback",value:function(){var t=function(t,e){if(e.metaKey&&"Meta"===T||e.ctrlKey&&"Control"===T){var n=t.querySelector('[hotkey="'+e.key+'"]');n&&(n.click(),e.preventDefault())}}.bind(null,this);this.field&&(this.field.addEventListener("keydown",t),A.set(this,t))}},{key:"disconnectedCallback",value:function(){var t=A.get(this);t&&this.field&&(this.field.removeEventListener("keydown",t),A.delete(this))}},{key:"field",get:function(){var t=this.getAttribute("for");if(t){var e=document.getElementById(t);return e instanceof HTMLTextAreaElement?e:null}}}]),e}(),A=new WeakMap;function P(t){return t.trim().split("\n").length>1}function L(t,e){return Array(e+1).join(t)}window.customElements.get("markdown-toolbar")||(window.MarkdownToolbarElement=M,window.customElements.define("markdown-toolbar",M));var D=null;function I(t,e){var n=t.value.slice(t.selectionStart,t.selectionEnd),o=void 0;o=e.orderedList?function(t){var e=/^\d+\.\s+/,n=void 0,o=void 0,i=t.value.slice(t.selectionStart,t.selectionEnd),r=i.split("\n");if(r.every(function(t){return e.test(t)}))r=r.map(function(t){return t.replace(e,"")}),i=r.join("\n");else{r=function(){var t=void 0,e=void 0,n=void 0,o=[];for(n=t=0,e=r.length;t<e;n=++t){var i=r[n];o.push(n+1+". "+i)}return o}(),i=r.join("\n");var l=F(t),a=l.newlinesToAppend,s=l.newlinesToPrepend;o=t.selectionStart+a.length,n=o+i.length,i=a+i+s}return{text:i,selectionStart:o,selectionEnd:n}}(t):e.multiline&&P(n)?function(t,e){var n=e.prefix,o=e.suffix,i=e.surroundWithNewlines,r=t.value.slice(t.selectionStart,t.selectionEnd),l=t.selectionStart,a=t.selectionEnd,s=r.split("\n");if(s.every(function(t){return t.startsWith(n)&&t.endsWith(o)}))r=s.map(function(t){return t.slice(n.length,t.length-o.length)}).join("\n"),a=l+r.length;else if(r=s.map(function(t){return n+t+o}).join("\n"),i){var c=F(t),u=c.newlinesToAppend,f=c.newlinesToPrepend;l+=u.length,a=l+r.length,r=u+r+f}return{text:r,selectionStart:l,selectionEnd:a}}(t,e):function(t,e){var n=void 0,o=void 0,i=e.prefix,r=e.suffix,l=e.blockPrefix,a=e.blockSuffix,s=e.replaceNext,c=e.prefixSpace,u=e.scanFor,f=e.surroundWithNewlines,d=t.selectionStart,h=t.selectionEnd,p=t.value.slice(t.selectionStart,t.selectionEnd),m=P(p)&&l.length>0?l+"\n":i,v=P(p)&&a.length>0?"\n"+a:r;if(c){var g=t.value[t.selectionStart-1];0===t.selectionStart||null==g||g.match(/\s/)||(m=" "+m)}p=function(t,e,n){if(t.selectionStart===t.selectionEnd)t.selectionStart=function(t,e){for(;t[e]&&null!=t[e-1]&&!t[e-1].match(/\s/);)e--;return e}(t.value,t.selectionStart),t.selectionEnd=function(t,e){for(;t[e]&&!t[e].match(/\s/);)e++;return e}(t.value,t.selectionEnd);else{var o=t.selectionStart-e.length,i=t.selectionEnd+n.length,r=t.value.slice(o,t.selectionStart)===e,l=t.value.slice(t.selectionEnd,i)===n;r&&l&&(t.selectionStart=o,t.selectionEnd=i)}return t.value.slice(t.selectionStart,t.selectionEnd)}(t,m,v);var y=t.selectionStart,w=t.selectionEnd,b=s.length>0&&v.indexOf(s)>-1&&p.length>0;if(f){var _=F(t);n=_.newlinesToAppend,o=_.newlinesToPrepend,m=n+i,v+=o}if(p.startsWith(m)&&p.endsWith(v)){var E=p.slice(m.length,p.length-v.length);if(d===h){var C=d-m.length;C=Math.max(C,y),C=Math.min(C,y+E.length),y=w=C}else w=y+E.length;return{text:E,selectionStart:y,selectionEnd:w}}if(b){if(u.length>0&&p.match(u)){v=v.replace(s,p);var k=m+v;return y=w=y+m.length,{text:k,selectionStart:y,selectionEnd:w}}var x=m+p+v;return y=y+m.length+p.length+v.indexOf(s),w=y+s.length,{text:x,selectionStart:y,selectionEnd:w}}var O=m+p+v;y=d+m.length,w=h+m.length;var S=p.match(/^\s*|\s*$/g);if(e.trimFirst&&S){var j=S[0]||"",N=S[1]||"";O=j+m+p.trim()+v+N,y+=j.length,w-=N.length}return{text:O,selectionStart:y,selectionEnd:w}}(t,e),function(t,e){var n=e.text,o=e.selectionStart,i=e.selectionEnd,r=t.selectionStart,l=t.value.slice(0,r),a=t.value.slice(t.selectionEnd);if(null===D||!0===D){t.contentEditable="true";try{D=document.execCommand("insertText",!1,n)}catch(t){D=!1}t.contentEditable="false"}if(D&&!t.value.slice(0,t.selectionStart).endsWith(n)&&(D=!1),!D){try{document.execCommand("ms-beginUndoUnit")}catch(t){}t.value=l+n+a;try{document.execCommand("ms-endUndoUnit")}catch(t){}t.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}null!=o&&null!=i?t.setSelectionRange(o,i):t.setSelectionRange(r,t.selectionEnd)}(t,o)}function F(t){var e=t.value.slice(0,t.selectionStart),n=t.value.slice(t.selectionEnd),o=e.match(/\n*$/),i=n.match(/^\n*/),r=o?o[0].length:0,l=i?i[0].length:0,a=void 0,s=void 0;return e.match(/\S/)&&r<2&&(a=L("\n",2-r)),n.match(/\S/)&&l<2&&(s=L("\n",2-l)),null==a&&(a=""),null==s&&(s=""),{newlinesToAppend:a,newlinesToPrepend:s}}function H(t,e){var n=t.closest("markdown-toolbar");if(n instanceof M){var o=c({},{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,trimFirst:!1},e),i=n.field;i&&(i.focus(),I(i,o))}}var K=n(3),R=n.n(K);app.initializers.add("flarum-markdown",function(t){var e=1;Object(i.extend)(l.a.prototype,"init",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,"configTextarea",function(t,e,n,o){if(!n){var i=new R.a(e);i.disableInline(),o.onunload=function(){i.destroy()}}}),Object(i.extend)(l.a.prototype,"toolbarItems",function(e){var n={className:"Button Button--icon Button--link",config:function(t){return $(t).tooltip()}},i=function(e){return t.translator.trans("flarum-markdown.forum.composer."+e+"_tooltip")};e.add("markdown",m("markdown-toolbar",{for:this.textareaId},m("md-header",o({title:i("header")},n),s()("fas fa-heading")),m("md-bold",o({title:i("bold")+" <cmd-b>"},n),s()("fas fa-bold")),m("md-italic",o({title:i("italic")+" <cmd-i>"},n),s()("fas fa-italic")),m("md-quote",o({title:i("quote")},n),s()("fas fa-quote-left")),m("md-code",o({title:i("code")},n),s()("fas fa-code")),m("md-link",o({title:i("link")+" <cmd-k>"},n),s()("fas fa-link")),m("md-unordered-list",o({title:i("unordered_list")},n),s()("fas fa-list-ul")),m("md-ordered-list",o({title:i("ordered_list")},n),s()("fas fa-list-ol"))),100)})})}]);
|
|
//# sourceMappingURL=forum.js.map
|