markdown-text-editor 2.0.0-beta.2 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/markdown-text-editor.es.js +35 -20
- package/dist/markdown-text-editor.es.js.map +1 -1
- package/dist/markdown-text-editor.min.js +9 -10
- package/dist/markdown-text-editor.min.js.map +1 -1
- package/dist/markdown-text-editor.umd.js +9 -10
- package/dist/markdown-text-editor.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +10 -0
|
@@ -68,13 +68,13 @@ ${e}</tr>
|
|
|
68
68
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${M(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?M(n,!0):this.parser.parseInline(r),o=Ye(e);if(o===null)return a;e=M(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+M(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Ye(e);if(i===null)return M(n);e=i;let a=`<img src="${M(e)}" alt="${M(n)}"`;return t&&(a+=` title="${M(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:M(e.text)}},it=class{parser;strong({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}em({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}codespan({text:e}){return e}del({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}html({text:e}){return e}text({text:e}){return e}link({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}image({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}br(){return``}checkbox({raw:e}){return e}},L=class e{options;renderer;textRenderer;constructor(e){this.options=e||t,this.options.renderer=this.options.renderer||new rt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new it,this.textRenderer.parser=this}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},at=class{options;block;constructor(e){this.options=e||t}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?I.lex:I.lexInline}provideParser(e=this.block){return e?L.parse:L.parseInline}};function ot(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var st=class{defaults=e();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=L;Renderer=rt;TextRenderer=it;Lexer=I;Tokenizer=F;Hooks=at;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(ot(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)ot(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)ot(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;ot(n,this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);ot(n,this.walkTokens(i,t))}):e.tokens&&ot(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new rt(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new F(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new at;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=at.passThroughHooks.has(n)?e=>{if(t.options.async&&at.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(t.options.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&ot(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return I.lex(e,t??this.defaults)}parser(e,t){return L.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?I.lex:I.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?L.parse:L.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?I.lex:I.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?L.parse:L.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
69
69
|
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+M(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},ct=new st;function R(e,t){return ct.parse(e,t)}R.options=R.setOptions=function(e){return ct.setOptions(e),R.defaults=ct.defaults,n(R.defaults),R},R.getDefaults=e,R.defaults=t;function lt(...e){return ct.use(...e),R.defaults=ct.defaults,n(R.defaults),R}R.use=lt,R.walkTokens=function(e,t){return ct.walkTokens(e,t)},R.parseInline=ct.parseInline,R.Parser=L,R.parser=L.parse,R.Renderer=rt,R.TextRenderer=it,R.Lexer=I,R.lexer=I.lex,R.Tokenizer=F,R.Hooks=at,R.parse=R,R.options,R.setOptions,R.walkTokens,R.parseInline,L.parse,I.lex;function ut(e,t){this.v=e,this.k=t}function dt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ft(e){if(Array.isArray(e))return e}function pt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function mt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
70
70
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ht(e,t){return ft(e)||pt(e,t)||gt(e,t)||mt()}function gt(e,t){if(e){if(typeof e==`string`)return dt(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dt(e,t):void 0}}function _t(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof ut;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}_t.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},_t.prototype.next=function(e){return this._invoke(`next`,e)},_t.prototype.throw=function(e){return this._invoke(`throw`,e)},_t.prototype.return=function(e){return this._invoke(`return`,e)};var vt=Object.entries,yt=Object.setPrototypeOf,bt=Object.isFrozen,xt=Object.getPrototypeOf,St=Object.getOwnPropertyDescriptor,z=Object.freeze,B=Object.seal,Ct=Object.create,wt=typeof Reflect<`u`&&Reflect,Tt=wt.apply,Et=wt.construct;z||=function(e){return e},B||=function(e){return e},Tt||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},Et||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var V=G(Array.prototype.forEach);Array.prototype.indexOf;var Dt=G(Array.prototype.lastIndexOf),Ot=G(Array.prototype.pop),kt=G(Array.prototype.push),At=G(Array.prototype.slice),jt=G(Array.prototype.splice),Mt=Array.isArray,Nt=qt(Set),Pt=G(Set.prototype.add),Ft=G(Set.prototype.has),It=G(String.prototype.toLowerCase),Lt=G(String.prototype.toString),Rt=G(String.prototype.match),zt=G(String.prototype.replace),Bt=G(String.prototype.indexOf),Vt=G(String.prototype.trim),Ht=G(Number.prototype.toString),Ut=G(Boolean.prototype.toString),Wt=typeof BigInt>`u`?null:G(BigInt.prototype.toString),Gt=typeof Symbol>`u`?null:G(Symbol.prototype.toString),H=G(Object.prototype.hasOwnProperty),Kt=G(Object.prototype.toString),U=G(RegExp.prototype.test),W=qt(TypeError);function G(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Tt(e,t,r)}}function qt(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return Et(e,n)}}function K(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:It;if(yt&&yt(e,null),!Mt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(bt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Jt(e){for(let t=0;t<e.length;t++)H(e,t)||(e[t]=null);return e}function q(e){let t=Ct(null);for(let r of vt(e)){var n=ht(r,2);let i=n[0],a=n[1];H(e,i)&&(t[i]=Mt(a)?Jt(a):a&&typeof a==`object`&&a.constructor===Object?q(a):a)}return t}function Yt(e){switch(typeof e){case`string`:return e;case`number`:return Ht(e);case`boolean`:return Ut(e);case`bigint`:return Wt?Wt(e):`0`;case`symbol`:return Gt?Gt(e):`Symbol()`;case`undefined`:return Kt(e);case`function`:case`object`:{if(e===null)return Kt(e);let t=e,n=J(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Kt(e)}return Kt(e)}default:return Kt(e)}}function J(e,t){for(;e!==null;){let n=St(e,t);if(n){if(n.get)return G(n.get);if(typeof n.value==`function`)return G(n.value)}e=xt(e)}function n(){return null}return n}function Xt(e,t){for(;e!==null;){let n=St(e,t);if(n)return n.get?G(n.get):null;e=xt(e)}return null}function Zt(e){try{return U(e,``),!0}catch{return!1}}var Qt=z(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),$t=z(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),en=z([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),tn=z([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),nn=z(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),rn=z([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),an=z([`#text`]),on=z(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),sn=z(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),cn=z(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),ln=z([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),un=B(/{{[\w\W]*|^[\w\W]*}}/g),dn=B(/<%[\w\W]*|^[\w\W]*%>/g),fn=B(/\${[\w\W]*/g),pn=B(/^data-[\-\w.\u00B7-\uFFFF]+$/),mn=B(/^aria-[\-\w]+$/),hn=B(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),gn=B(/^(?:\w+script|data):/i),_n=B(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),vn=B(/^html$/i),yn=B(/^[a-z][.\w]*(-[.\w]+)+$/i),bn=B(/<[/\w!]/g),xn=B(/<[/\w]/g),Sn=B(/<\/no(script|embed|frames)/i),Cn=B(/\/>/i),Y={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},wn=z(K({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),Tn=function(){return typeof window>`u`?null:window},En=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Dn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},On=function(e,t,n,r){return H(e,t)&&Mt(e[t])?K(r.base?q(r.base):{},e[t],r.transform):n},kn=function(e,t,n){let r=H(e,t)?e[t]:void 0;return r&&typeof r==`object`?q(r):n()};function An(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tn(),t=e=>An(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==Y.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=J(d,`cloneNode`),p=J(d,`remove`),m=J(d,`removeAttributeNode`),h=J(d,`nextSibling`),g=J(d,`childNodes`),_=J(d,`parentNode`),v=J(d,`shadowRoot`),ee=J(d,`attributes`),te=o&&o.prototype?J(o.prototype,`nodeType`):null,ne=o&&o.prototype?J(o.prototype,`nodeName`):null,y=o&&o.prototype?J(o.prototype,`ownerDocument`):null,b=function(e){return te?te(e):e.nodeType},re=function(e){return ne?ne(e):e.nodeName},ie=Xt(d,`namespaceURI`),ae=function(e){return ie?ie(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,oe,se=!1,ce=0,le=function(){if(ce>0)throw W(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ue=function(e){le(),ce++;try{return x.createHTML(e)}finally{ce--}},de=function(e){le(),ce++;try{return x.createScriptURL(e)}finally{ce--}},fe=function(){return se||=(oe=En(u,i),!0),oe},C=n,w=C.implementation,pe=C.createNodeIterator,me=C.createDocumentFragment,he=C.getElementsByTagName,ge=r.importNode,T=Dn();t.isSupported=typeof vt==`function`&&typeof _==`function`&&w&&w.createHTMLDocument!==void 0;let _e=un,ve=dn,ye=fn,be=pn,xe=mn,Se=gn,Ce=_n,we=yn,Te=hn,E=null,Ee=K({},[...Qt,...$t,...en,...nn,...an]),D=null,De=K({},[...on,...sn,...cn,...ln]),O=Object.seal(Ct(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Oe=null,ke=null,k=Object.seal(Ct(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ae=!0,je=!0,Me=!1,Ne=!0,A=!1,Pe=!0,Fe=!1,Ie=!1,Le=null,Re=null,ze=!1,Be=!1,Ve=!1,He=!1,Ue=!0,We=!1,Ge=`user-content-`,Ke=!0,qe=!1,j=null,M={},Je=null,Ye=K({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Xe=null,N=K({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ze=null,Qe=K({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),$e=`http://www.w3.org/1998/Math/MathML`,et=`http://www.w3.org/2000/svg`,P=`http://www.w3.org/1999/xhtml`,tt=P,nt=!1,F=null,I=K({},[$e,et,P],Lt),rt=z([`mi`,`mo`,`mn`,`ms`,`mtext`]),it=K({},rt),L=z([`annotation-xml`]),at=K({},L),ot=K({},[`title`,`style`,`font`,`a`,`script`]),st=null,ct=[`application/xhtml+xml`,`text/html`],R=null,lt=null,ut=n.createElement(`form`),dt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(lt&<===e)return;e&&typeof e==`object`||(e={}),e=q(e),st=ct.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,R=st===`application/xhtml+xml`?Lt:It,E=On(e,`ALLOWED_TAGS`,Ee,{transform:R}),D=On(e,`ALLOWED_ATTR`,De,{transform:R}),F=On(e,`ALLOWED_NAMESPACES`,I,{transform:Lt}),Ze=On(e,`ADD_URI_SAFE_ATTR`,Qe,{transform:R,base:Qe}),Xe=On(e,`ADD_DATA_URI_TAGS`,N,{transform:R,base:N}),Je=On(e,`FORBID_CONTENTS`,Ye,{transform:R}),Oe=On(e,`FORBID_TAGS`,q({}),{transform:R}),ke=On(e,`FORBID_ATTR`,q({}),{transform:R}),M=H(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?q(e.USE_PROFILES):e.USE_PROFILES:!1,Ae=e.ALLOW_ARIA_ATTR!==!1,je=e.ALLOW_DATA_ATTR!==!1,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,A=e.SAFE_FOR_TEMPLATES||!1,Pe=e.SAFE_FOR_XML!==!1,Fe=e.WHOLE_DOCUMENT||!1,Be=e.RETURN_DOM||!1,Ve=e.RETURN_DOM_FRAGMENT||!1,He=e.RETURN_TRUSTED_TYPE||!1,ze=e.FORCE_BODY||!1,Ue=e.SANITIZE_DOM!==!1,We=e.SANITIZE_NAMED_PROPS||!1,Ke=e.KEEP_CONTENT!==!1,qe=e.IN_PLACE||!1,Te=Zt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:hn,tt=typeof e.NAMESPACE==`string`?e.NAMESPACE:P,it=kn(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>K({},rt)),at=kn(e,`HTML_INTEGRATION_POINTS`,()=>K({},L));let t=kn(e,`CUSTOM_ELEMENT_HANDLING`,()=>Ct(null));if(O=Ct(null),H(t,`tagNameCheck`)&&dt(t.tagNameCheck)&&(O.tagNameCheck=t.tagNameCheck),H(t,`attributeNameCheck`)&&dt(t.attributeNameCheck)&&(O.attributeNameCheck=t.attributeNameCheck),H(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(O.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),B(O),A&&(je=!1),Ve&&(Be=!0),M&&(E=K({},an),D=Ct(null),M.html===!0&&(K(E,Qt),K(D,on)),M.svg===!0&&(K(E,$t),K(D,sn),K(D,ln)),M.svgFilters===!0&&(K(E,en),K(D,sn),K(D,ln)),M.mathMl===!0&&(K(E,nn),K(D,cn),K(D,ln))),k.tagCheck=null,k.attributeCheck=null,H(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?k.tagCheck=e.ADD_TAGS:Mt(e.ADD_TAGS)&&(E===Ee&&(E=q(E)),K(E,e.ADD_TAGS,R))),H(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?k.attributeCheck=e.ADD_ATTR:Mt(e.ADD_ATTR)&&(D===De&&(D=q(D)),K(D,e.ADD_ATTR,R))),H(e,`ADD_FORBID_CONTENTS`)&&Mt(e.ADD_FORBID_CONTENTS)&&(Je===Ye&&(Je=q(Je)),K(Je,e.ADD_FORBID_CONTENTS,R)),Ke&&(E[`#text`]=!0),Fe&&K(E,[`html`,`head`,`body`]),E.table&&(K(E,[`tbody`]),delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw W(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw W(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=ue(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=fe()),x&&typeof S==`string`&&(S=ue(``)));z&&z(e),lt=e},pt=K({},[...$t,...en,...tn]),mt=K({},[...nn,...rn]),ht=function(e,t,n){return t.namespaceURI===P?e===`svg`:t.namespaceURI===$e?e===`svg`&&(n===`annotation-xml`||it[n]):!!pt[e]},gt=function(e,t,n){return t.namespaceURI===P?e===`math`:t.namespaceURI===et?e===`math`&&at[n]:!!mt[e]},_t=function(e,t,n){return t.namespaceURI===et&&!at[n]||t.namespaceURI===$e&&!it[n]?!1:!mt[e]&&(ot[e]||!pt[e])},yt=function(e){let t=ae(e),n=It(re(e)),r=_(e),i,a;return r&&b(r)===Y.element?(i={namespaceURI:ae(r)},a=It(re(r))):(i={namespaceURI:tt},a=`template`),F[t]?t===et?ht(n,i,a):t===$e?gt(n,i,a):t===P?_t(n,i,a):!!(st===`application/xhtml+xml`&&F[t]):!1},bt=function(e){kt(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw W(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},xt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},St=function(e){Ht(e);let t=g(e);t&&V(At(t),e=>{try{p(e)}catch{}});let n=b(e)===Y.element?ee(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&xt(e,r,i)}},wt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}kt(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Be||Ve)try{bt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Tt=function(e){let t=ee(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||D[R(i)]||xt(e,r,i)}},Et=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&b(e)===Y.element){let t=v(e);Z(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},Ht=function(e){Et(e,e=>{b(e)===Y.element&&Tt(e)})},Ut=function(e){let t=[];return Et(e,e=>{t.push(e)},!0),t},Wt=function(e,t){let n=Nt();V(Ut(e),e=>{b(e)===Y.element&&Pt(n,e)}),V(t,e=>{b(e)===Y.element&&!Ft(n,e)&&Tt(e)})},Gt=function(e,n){let r=!1;return V(t.removed,t=>{t.element&&(r||=t.element===e,Ht(t.element))}),Wt(e,n),r},Kt=function(e,t){let n=j,r=null,i=()=>(r||(r=Nt(),V(t,e=>{Pt(r,e)})),r);for(let t=0;;t++){let r=Ut(e),a=[e],o=!1;if(V(r,e=>{b(e)===Y.documentFragment?kt(a,e):!o&&!Ft(n,e)&&(o=Ft(i(),e))}),!o)return;if(t>=8)throw W(`the tree kept changing during in-place sanitization; refusing to return it`);V(a,(t,n)=>{G(t,n>0,e,i())})}},G=function(e,t,n,r){let i=Mn(e),a;for(;a=i.nextNode();)Ft(r,a)&&!Ft(j,a)&&(t&&Q(T.uponSanitizeShadowNode,a,null),Hn(a,n),Yn(a,n),Z(a.content)&&Xn(a.content))},qt=function(e){j&&Pt(j,e)},Jt=function(e,t){return Pe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},jn=function(e){Pe&&Et(e,e=>{let t=b(e);if(t===Y.processingInstruction||t===Y.comment&&U(xn,e.data)){try{p(e)}catch{}return!1}if(t===Y.element){let t=e,n=R(re(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Jt(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},X=function(e){let t=null,r=null;if(ze)e=`<remove></remove>`+e;else{let t=Rt(e,/^[\r\n\t ]+/);r=t&&t[0]}st===`application/xhtml+xml`&&tt===P&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?ue(e):e;if(tt===P)try{t=new l().parseFromString(i,st)}catch{}if(!t||!t.documentElement){t=w.createDocument(tt,`template`,null);try{t.documentElement.innerHTML=nt?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),tt===P?he.call(t,Fe?`html`:`body`)[0]:Fe?t.documentElement:a},Mn=function(e){let t=y?y(e):e.ownerDocument;return pe.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Nn=function(e){return e=zt(e,_e,` `),e=zt(e,ve,` `),e=zt(e,ye,` `),e},Pn=function(e){Fn(e);let t=e.querySelectorAll?.call(e,`template`);t&&V(t,e=>{Z(e.content)&&Pn(e.content)})},Fn=function(e){e.normalize();let t=y?y(e):e.ownerDocument,n=pe.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Nn(r.data),r=n.nextNode()},In=function(e){let t=ne?ne(e):null;return typeof t!=`string`||R(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ee(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==te(e)||e.childNodes!==g(e)},Z=function(e){if(!te||typeof e!=`object`||!e)return!1;try{return te(e)===Y.documentFragment}catch{return!1}},Ln=function(e){if(!te||typeof e!=`object`||!e)return!1;try{return typeof te(e)==`number`}catch{return!1}};function Q(e,n,r){e.length!==0&&V(e,e=>{e.call(t,n,r,lt)})}let Rn=function(e,t){return!!(Pe&&e.hasChildNodes()&&!Ln(e.firstElementChild)&&U(bn,e.textContent)&&U(bn,e.innerHTML)||Pe&&wn[t]&&b(e)===Y.element&&ae(e)===P&&(Ln(e.firstElementChild)||typeof e.textContent==`string`&&U(bn,e.textContent))||e.nodeType===Y.processingInstruction||Pe&&e.nodeType===Y.comment&&U(xn,e.data))},zn=function(e,t){if(e instanceof RegExp)return U(e,t);if(e instanceof Function){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return!!e(t,...r)}return!1},Bn=function(e,t,n){if(!Oe[t]&&Gn(t)&&zn(O.tagNameCheck,t))return!1;if(Ke&&!Je[t]&&!Je[It(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return bt(e),!0},Vn=function(e,t,n,r){return e.length===0?t:t===n||t===r?q(t):t},$=function(e,t){return e===t||_(e)!==null?!1:(qe&&Ht(e),!0)},Hn=function(e,n){if(qt(e),Q(T.beforeSanitizeElements,e,null),$(e,n))return!0;if(In(e))return bt(e),!0;let r=R(re(e));if(E=Vn(T.uponSanitizeElement,E,Ee,Le),Q(T.uponSanitizeElement,e,{tagName:r,allowedTags:E}),$(e,n))return!0;if(Rn(e,r))return bt(e),!0;if(Oe[r]||!(k.tagCheck instanceof Function&&k.tagCheck(r))&&!E[r]){let t=Bn(e,r,n);return t===!1&&(Q(T.afterSanitizeElements,e,null),$(e,n))?!0:t}if(b(e)===Y.element&&!yt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&U(Sn,e.innerHTML))return bt(e),!0;if(A&&e.nodeType===Y.text){let n=Nn(e.textContent);e.textContent!==n&&(kt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Q(T.afterSanitizeElements,e,null),$(e,n)},Un=function(e,t,r){if(ke[t]||Jt(t,e)||Ue&&(t===`id`||t===`name`)&&(r in n||r in ut))return!1;let i=D[t]||k.attributeCheck instanceof Function&&k.attributeCheck(t,e);return je&&U(be,t)||Ae&&U(xe,t)?!0:i?Ze[t]||U(Te,zt(r,Ce,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Bt(r,`data:`)===0&&Xe[e]||Me&&!U(Se,zt(r,Ce,``))?!0:!r:Gn(e)&&zn(O.tagNameCheck,e)&&zn(O.attributeNameCheck,t,e)||t===`is`&&O.allowCustomizedBuiltInElements&&zn(O.tagNameCheck,r)},Wn=K({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Gn=function(e){return!Wn[It(e)]&&U(we,e)},Kn=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ue(r);case`TrustedScriptURL`:return de(r)}return r},qn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!In(e)||(bt(e),!1)}catch{return wt(t,e),!1}},Jn=function(e,t){return Pe&&U(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:It(e)===`attributename`&&Rt(t,`href`)!==null},Yn=function(e,n){if(Q(T.beforeSanitizeAttributes,e,null),$(e,n))return;let r=e.attributes;if(!r||In(e))return;D=Vn(T.uponSanitizeAttribute,D,De,Re);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:D,forceKeepAttr:void 0},a=r.length,o=R(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=R(s),d=l,f=s===`value`?d:Vt(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Q(T.uponSanitizeAttribute,e,i),f=i.attrValue,We&&(u===`id`||u===`name`)&&Bt(f,Ge)!==0&&(wt(s,e,n),f=Ge+f,p=!0),Jn(s,f)?wt(s,e,n):i.forceKeepAttr||(i.keepAttr?!Ne&&U(Cn,f)?wt(s,e,n):(A&&(f=Nn(f)),Un(o,u,f)?(f=Kn(o,u,c,f),f!==d&&qn(e,s,c,f)&&p&&Ot(t.removed)):wt(s,e,n)):wt(s,e,n))}Q(T.afterSanitizeAttributes,e,null),$(e,n)},Xn=function(e){let t=null,n=Mn(e);for(Q(T.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Q(T.uponSanitizeShadowNode,t,null),Hn(t,e),Yn(t,e),Z(t.content)&&Xn(t.content),b(t)===Y.element){let e=v(t);Z(e)&&(Zn(e),Xn(e))}A&&Fn(e),Q(T.afterSanitizeShadowDOM,e,null)},Zn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Xn(e.shadow);continue}let n=e.node,r=b(n)===Y.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=ne?ne(n):null;if(typeof e==`string`&&R(e)===`template`){let e=n.content;Z(e)&&t.push({node:e,shadow:null})}}if(r){let e=v(n);Z(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(nt=!e,nt&&(e=`<!-->`),typeof e!=`string`&&!Ln(e)&&(e=Yt(e),typeof e!=`string`))throw W(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ie?(E=Le,D=Re):ft(n),(T.uponSanitizeElement.length>0||T.uponSanitizeAttribute.length>0)&&(E=q(E)),T.uponSanitizeAttribute.length>0&&(D=q(D)),t.removed=[];let c=qe&&typeof e!=`string`&&Ln(e),l=[],u=j;if(c){jn(e);let t=re(e);if(typeof t==`string`){let n=R(t);if(!E[n]||Oe[n])throw St(e),W(`root node is forbidden and cannot be sanitized in-place`)}if(In(e))throw St(e),W(`root node is clobbered and cannot be sanitized in-place`);l=Ut(e),j=Nt()}else if(Ln(e))i=X(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Y.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Zn(i);else{if(!Be&&!A&&!Fe&&e.indexOf(`<`)===-1)return x&&He?ue(e):e;if(i=X(e),!i)return Be?null:He?S:``}i&&ze&&bt(i.firstChild);let d=c?e:i;try{c&&Zn(e);let t=Mn(d);for(;o=t.nextNode();)Hn(o,d),Yn(o,d),Z(o.content)&&Xn(o.content);c&&Kt(e,l)}catch(t){throw c&&(St(e),Gt(e,l)),t}finally{j=u}if(c){if(Gt(e,l))throw W(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return A&&Pn(e),e}if(Be){if(A&&Pn(i),Ve)for(s=me.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(D.shadowroot||D.shadowrootmode)&&(s=ge.call(r,s,!0)),s}let f=Fe?i.outerHTML:i.innerHTML;return Fe&&E[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&U(vn,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
71
|
-
`+f),A&&(f=Nn(f)),x&&He?ue(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(e),Ie=!0,Le=E,Re=D},t.clearConfig=function(){lt=null,Ie=!1,Le=null,Re=null,x=oe,S=``},t.isValidAttribute=function(e,t,n){lt||ft({});let r=R(e),i=R(t);return typeof n==`string`&&(Jn(t,n)||!Ne&&U(Cn,n))?!1:Un(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&H(T,e)&&kt(T[e],t)},t.removeHook=function(e,t){if(H(T,e)){if(t!==void 0){let n=Dt(T[e],t);return n===-1?void 0:jt(T[e],n,1)[0]}return Ot(T[e])}},t.removeHooks=function(e){H(T,e)&&(T[e]=[])},t.removeAllHooks=function(){T=Dn()},t}var jn=An(),X=class{constructor(e,t){this.editor=e,this.defaultText=`${t} text`,this.button=this.createButton(),this.title=t}createButton(e){let t=document.createElement(`button`),n=this.title?`${this.title.replace(/ /g,`-`)}-btn`.toLowerCase():``;t.innerHTML=e;let r=t.querySelector(`svg`);if(r&&r.setAttribute(`aria-hidden`,`true`),t.type=`button`,t.title=this.title?this.editor.label(this.title):this.title,t.className=`markdown-btn ${n} fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost`,t.addEventListener(`click`,e=>this.applySyntax(e)),n==`preview-btn`){let e=document.createElement(`div`);return e.className=`fj:me-surface fj:me-surface-outline fj:border-base-soft fj:border-0 fj:border-l fj:sticky fj:-right-2 fj:px-1.5`,e.appendChild(t),e}return t}},Mn=class extends X{constructor(e){super(e,`Bold`),this.button=this.createButton(`
|
|
71
|
+
`+f),A&&(f=Nn(f)),x&&He?ue(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ft(e),Ie=!0,Le=E,Re=D},t.clearConfig=function(){lt=null,Ie=!1,Le=null,Re=null,x=oe,S=``},t.isValidAttribute=function(e,t,n){lt||ft({});let r=R(e),i=R(t);return typeof n==`string`&&(Jn(t,n)||!Ne&&U(Cn,n))?!1:Un(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&H(T,e)&&kt(T[e],t)},t.removeHook=function(e,t){if(H(T,e)){if(t!==void 0){let n=Dt(T[e],t);return n===-1?void 0:jt(T[e],n,1)[0]}return Ot(T[e])}},t.removeHooks=function(e){H(T,e)&&(T[e]=[])},t.removeAllHooks=function(){T=Dn()},t}var jn=An(),X=class{constructor(e,t){this.editor=e,this.defaultText=`${t} text`,this.button=this.createButton(),this.title=t}trimSelection(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n,value:r}=e;if(t===n)return;let i=t,a=n;for(;i<a&&/\s/.test(r[i]);)i++;for(;a>i&&/\s/.test(r[a-1]);)a--;i!==a&&(i!==t||a!==n)&&e.setSelectionRange(i,a)}createButton(e){let t=document.createElement(`button`),n=this.title?`${this.title.replace(/ /g,`-`)}-btn`.toLowerCase():``;t.innerHTML=e;let r=t.querySelector(`svg`);if(r&&r.setAttribute(`aria-hidden`,`true`),t.type=`button`,t.title=this.title?this.editor.label(this.title):this.title,t.className=`markdown-btn ${n} fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost`,t.addEventListener(`click`,e=>this.applySyntax(e)),n==`preview-btn`){let e=document.createElement(`div`);return e.className=`fj:me-surface fj:me-surface-outline fj:border-base-soft fj:border-0 fj:border-l fj:sticky fj:-right-2 fj:px-1.5`,e.appendChild(t),e}return t}},Mn=class extends X{constructor(e){super(e,`Bold`),this.button=this.createButton(`
|
|
72
72
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 5h6a3.5 3.5 0 0 1 0 7h-6l0 -7" /><path d="M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7" /></svg>
|
|
73
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`*`+i.slice(3,-3)+`*`;else if(i.startsWith(`**`)&&i.endsWith(`**`))a=i.slice(2,-2);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`*${i}*`,1,1);return}else if(r.substring(t-2,t)===`**`&&r.substring(n,n+2)===`**`&&r[t-3]!==`*`&&r[n+2]!==`*`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`**${i||`Bold text`}**`,i||(o=2);this.editor.insertText(a,o,o)}},Nn=class extends X{constructor(e){super(e,`Italic`),this.button=this.createButton(`
|
|
73
|
+
`)}applySyntax(){this.trimSelection();let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`*`+i.slice(3,-3)+`*`;else if(i.startsWith(`**`)&&i.endsWith(`**`))a=i.slice(2,-2);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`*${i}*`,1,1);return}else if(r.substring(t-2,t)===`**`&&r.substring(n,n+2)===`**`&&r[t-3]!==`*`&&r[n+2]!==`*`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`**${i||`Bold text`}**`,i||(o=2);this.editor.insertText(a,o,o)}},Nn=class extends X{constructor(e){super(e,`Italic`),this.button=this.createButton(`
|
|
74
74
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11 5l6 0" /><path d="M7 19l6 0" /><path d="M14 5l-4 14" /></svg>
|
|
75
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`**`+i.slice(3,-3)+`**`;else if(i.startsWith(`*`)&&i.endsWith(`*`)&&!i.startsWith(`**`))a=i.slice(1,-1);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`**${i}**`,2,2);return}else if(r[t-1]===`*`&&r[n]===`*`&&r[t-2]!==`*`&&r[n+1]!==`*`){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}else a=`*${i||`Italic text`}*`,i||(o=1);this.editor.insertText(a,o,o)}},Pn=class extends X{constructor(e){super(e,`Strikethrough`),this.button=this.createButton(`
|
|
75
|
+
`)}applySyntax(){this.trimSelection();let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`***`)&&i.endsWith(`***`))a=`**`+i.slice(3,-3)+`**`;else if(i.startsWith(`*`)&&i.endsWith(`*`)&&!i.startsWith(`**`))a=i.slice(1,-1);else if(r.substring(t-3,t)===`***`&&r.substring(n,n+3)===`***`){e.setSelectionRange(t-3,n+3),this.editor.insertText(`**${i}**`,2,2);return}else if(r[t-1]===`*`&&r[n]===`*`&&r[t-2]!==`*`&&r[n+1]!==`*`){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}else a=`*${i||`Italic text`}*`,i||(o=1);this.editor.insertText(a,o,o)}},Pn=class extends X{constructor(e){super(e,`Strikethrough`),this.button=this.createButton(`
|
|
76
76
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l14 0" /><path d="M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5" /></svg>
|
|
77
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`~~`)&&i.endsWith(`~~`))a=i.slice(2,-2);else if(r.substring(t-2,t)===`~~`&&r.substring(n,n+2)===`~~`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`~~${i||`Strikethrough text`}~~`,o=2;this.editor.insertText(a,o,o)}},Fn=class extends X{constructor(e){super(e,`Unordered list`),this.button=this.createButton(`
|
|
77
|
+
`)}applySyntax(){this.trimSelection();let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`~~`)&&i.endsWith(`~~`))a=i.slice(2,-2);else if(r.substring(t-2,t)===`~~`&&r.substring(n,n+2)===`~~`){e.setSelectionRange(t-2,n+2),this.editor.insertText(i,0,0);return}else a=`~~${i||`Strikethrough text`}~~`,o=2;this.editor.insertText(a,o,o)}},Fn=class extends X{constructor(e){super(e,`Unordered list`),this.button=this.createButton(`
|
|
78
78
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 6l11 0" /><path d="M9 12l11 0" /><path d="M9 18l11 0" /><path d="M5 6l0 .01" /><path d="M5 12l0 .01" /><path d="M5 18l0 .01" /></svg>
|
|
79
79
|
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n),a=``,o=0;if(i.startsWith(`- `))a=i.slice(2);else if(r.substring(t-2,t)===`- `){e.setSelectionRange(t-2,n),this.editor.insertText(i,0,0);return}else a=`- ${i||`Unordered list`}`,o=2;this.editor.insertText(a,o)}},In=class extends X{constructor(e){super(e,`Ordered list`),this.button=this.createButton(`
|
|
80
80
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M11 6h9" /><path d="M11 12h9" /><path d="M12 18h8" /><path d="M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4" /><path d="M6 10v-6l-2 2" /></svg>
|
|
@@ -92,7 +92,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
92
92
|
</dialog>
|
|
93
93
|
`;i.querySelector(`.markdown-modal`)||i.insertAdjacentHTML(`beforeend`,a);let o=i.querySelector(`.markdown-modal`);return o.addEventListener(`close`,()=>o.remove()),o.showModal(),o}var zn=class extends X{constructor(e){super(e,`Link`),this.button=this.createButton(`
|
|
94
94
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 15l6 -6" /><path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" /><path d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" /></svg>
|
|
95
|
-
`)}applySyntax(e){let t=this.editor,n=t.usertextarea,{selectionStart:r,selectionEnd:i}=n,a=n.value,o=a.substring(0,r),s=a.substring(i);if(o.endsWith(`[`)&&/^\]\([^)]+\)/.test(s)){let e=s.match(/^\]\(([^)]+)\)/);e&&(r=o.length-1,i+=e[0].length,n.setSelectionRange(r,i))}let c=a.substring(r,i),l=c&&c.match(/^\[([^\]]+)\]\(([^)]+)\)$/),u=l?l[1]:c,d=l?l[2]:``,f=Rn(e,`fj:max-w-sm`,`
|
|
95
|
+
`)}applySyntax(e){this.trimSelection();let t=this.editor,n=t.usertextarea,{selectionStart:r,selectionEnd:i}=n,a=n.value,o=a.substring(0,r),s=a.substring(i);if(o.endsWith(`[`)&&/^\]\([^)]+\)/.test(s)){let e=s.match(/^\]\(([^)]+)\)/);e&&(r=o.length-1,i+=e[0].length,n.setSelectionRange(r,i))}let c=a.substring(r,i),l=c&&c.match(/^\[([^\]]+)\]\(([^)]+)\)$/),u=l?l[1]:c,d=l?l[2]:``,f=Rn(e,`fj:max-w-sm`,`
|
|
96
96
|
<div class="fj:flex fj:justify-between fj:items-center fj:gap-3">
|
|
97
97
|
<div class="fj:font-medium">${this.editor.label(`Link`)}</div>
|
|
98
98
|
<button type="button" class="modal-close-btn fj:me-btn fj:me-btn-ghost fj:me-btn-xs fj:me-btn-circle" aria-label="${this.editor.label(`Close`)}">
|
|
@@ -136,7 +136,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
136
136
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M20 6l-7 0" /><path d="M20 12l-9 0" /><path d="M20 18l-7 0" /><path d="M8 8l-4 4l4 4" /></svg>
|
|
137
137
|
`)}applySyntax(e){let t=this.editor.indentManager;t&&(t.outdent(),this.editor.render())}},Jn=class extends X{constructor(e){super(e,`Code`),this.button=this.createButton(`
|
|
138
138
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 8l-4 4l4 4" /><path d="M17 8l4 4l-4 4" /><path d="M14 4l-4 16" /></svg>
|
|
139
|
-
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n);if(i.startsWith("`")&&i.endsWith("`")){this.editor.insertText(i.slice(1,-1),0,0);return}if(r[t-1]==="`"&&r[n]==="`"){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}let a=`\`${i||`code`}\``;this.editor.insertText(a,1,1)}},Yn=class extends X{constructor(e){super(e,`Code Block`),this.button=this.createButton(`
|
|
139
|
+
`)}applySyntax(){this.trimSelection();let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value,i=r.substring(t,n);if(i.startsWith("`")&&i.endsWith("`")){this.editor.insertText(i.slice(1,-1),0,0);return}if(r[t-1]==="`"&&r[n]==="`"){e.setSelectionRange(t-1,n+1),this.editor.insertText(i,0,0);return}let a=`\`${i||`code`}\``;this.editor.insertText(a,1,1)}},Yn=class extends X{constructor(e){super(e,`Code Block`),this.button=this.createButton(`
|
|
140
140
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M8 9l3 3l-3 3" /><path d="M13 15l3 0" /><rect x="3" y="4" width="18" height="16" rx="2" /></svg>
|
|
141
141
|
`)}applySyntax(){let e=this.editor.usertextarea,{selectionStart:t,selectionEnd:n}=e,r=e.value.substring(t,n);if(r.startsWith("```")&&r.endsWith("```")&&r.length>6){let e=r.replace(/^```\w*\n?/,``).replace(/\n?```$/,``);this.editor.insertText(e,0,0);return}let i=`\`\`\`\n${r||`code`}\n\`\`\``;this.editor.insertText(i,4,4)}},Xn=class extends X{constructor(e){super(e,`Horizontal Rule`),this.button=this.createButton(`
|
|
142
142
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 12l16 0" stroke-width="3"/><path d="M4 7l6 0" /><path d="M4 17l6 0" /><path d="M14 7l6 0" /><path d="M14 17l6 0" /></svg>
|
|
@@ -173,9 +173,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
173
173
|
`),s=0,c=0,l=o.map((e,t)=>e.startsWith(` `)?(t===0&&(s=1),c++,e.substring(1)):e.startsWith(` `)?(t===0&&(s=4),c+=4,e.substring(4)):e).join(`
|
|
174
174
|
`);this._applyChange(r.substring(0,i)+l+r.substring(a),Math.max(i,t-s),Math.max(i,n-c))}_applyChange(e,t,n){this.textarea.value=e,this.textarea.setSelectionRange(t,n)}},kr=class{constructor(e){this.editor=e,this.textarea=e.usertextarea,this._keydownHandler=e=>{e.key===`Enter`&&this.handleEnter(e)},this.textarea.addEventListener(`keydown`,this._keydownHandler)}destroy(){this.textarea.removeEventListener(`keydown`,this._keydownHandler)}handleEnter(e){let{selectionStart:t,value:n}=this.textarea,r=n.lastIndexOf(`
|
|
175
175
|
`,t-1)+1,i=n.substring(r,t),a=i.match(/^(\s*)(\d+)\.\s/),o=i.match(/^(\s*)([\-\*] )\[[\s xX]\] /),s=i.match(/^(\s*)([\-\*] )\s*/);if(i.match(/^(\s*)(\d+\.\s|[\-\*] \[[\s xX]\] |[\-\*]\s)$/)){e.preventDefault();let i=n.substring(0,r),a=n.substring(t);this.textarea.value=i+`
|
|
176
|
-
`+a,this.textarea.setSelectionRange(r+1,r+1),this.editor.render(),this.editor.notifyChange();return}let c=null;if(a?c=`${a[1]}${parseInt(a[2])+1}. `:o?c=`${o[1]}${o[2]}[ ] `:s&&(c=`${s[1]}${s[2]}`),c){e.preventDefault();let r=`\n${c}`,i=n.substring(0,t),a=n.substring(t);this.textarea.value=i+r+a;let o=t+r.length;this.textarea.setSelectionRange(o,o),this.editor.render(),this.editor.notifyChange()}}},Ar=[{key:`b`,ctrl:!0,shift:!1,ToolClass:Mn,label:`Ctrl+B`,btnClass:`bold-btn`},{key:`i`,ctrl:!0,shift:!1,ToolClass:Nn,label:`Ctrl+I`,btnClass:`italic-btn`},{key:`k`,ctrl:!0,shift:!1,ToolClass:zn,label:`Ctrl+K`,btnClass:`link-btn`},{key:"`",ctrl:!0,shift:!1,ToolClass:Jn,label:"Ctrl+`",btnClass:`code-btn`},{key:`s`,ctrl:!0,shift:!0,ToolClass:Pn,label:`Ctrl+Shift+S`,btnClass:`strikethrough-btn`},{key:`l`,ctrl:!0,shift:!1,ToolClass:Fn,label:`Ctrl+L`,btnClass:`ul-btn`}];function jr(e){let t=String(e).split(`+`).map(e=>e.trim().toLowerCase()),n=t.pop();return n?{key:n,ctrl:t.includes(`ctrl`)||t.includes(`cmd`)||t.includes(`meta`),shift:t.includes(`shift`),alt:t.includes(`alt`)}:null}var Mr=class{constructor(e){this.editor=e,this.toolShortcuts=(e.toolbarInstance?.tools??[]).filter(e=>e.shortcut).map(e=>({tool:e,combo:jr(e.shortcut)})).filter(e=>e.combo);let t=(e.toolbarInstance?.tools??[]).find(e=>e instanceof $);this.headingLevels=t?.levels??[1,2,3,4,5,6],this._handler=this._onKeyDown.bind(this),this._docHandler=this._onDocKeyDown.bind(this),e.usertextarea.addEventListener(`keydown`,this._handler),document.addEventListener(`keydown`,this._docHandler),this._updateTooltips()}_onKeyDown(e){let t=e.ctrlKey||e.metaKey,n=e.shiftKey,r=e.key.toLowerCase();if(t&&n&&r===`f`)e.preventDefault(),this.editor.editorContainer.querySelector(`.preview-btn`)?.click();else if(t&&!n&&[`1`,`2`,`3`].includes(e.key)&&this.headingLevels.includes(parseInt(e.key)))e.preventDefault(),new $(this.editor).applyHeading(parseInt(e.key));else{for(let{tool:i,combo:a}of this.toolShortcuts)if(r===a.key&&t===a.ctrl&&n===a.shift&&e.altKey===a.alt){e.preventDefault(),i.applySyntax(e);return}for(let i of Ar)if(r===i.key&&t===i.ctrl&&n===i.shift){e.preventDefault(),new i.ToolClass(this.editor).applySyntax(e);return}}}_onDocKeyDown(e){if(e.key===`F11`){let t=this.editor.editorContainer.contains(document.activeElement),n=this.editor.editorContainer.classList.contains(`is-fullscreen`);(t||n)&&(e.preventDefault(),this.editor.editorContainer.querySelector(`.preview-btn`)?.click())}}_updateTooltips(){for(let{btnClass:e,label:t}of Ar){let n=this.editor.editorContainer.querySelector(`.${e}`);n&&(n.title+=` (${t})`)}let e=this.editor.editorContainer.querySelector(`.heading-btn`),t=this.headingLevels.filter(e=>e<=3);e&&t.length&&(e.title+=` (Ctrl+${t.join(`/`)})`);let n=this.editor.editorContainer.querySelector(`.preview-btn`);n&&(n.title+=` (F11)`);for(let{tool:e}of this.toolShortcuts)e.button&&(e.button.title+=` (${e.shortcut})`)}destroy(){this.editor.usertextarea.removeEventListener(`keydown`,this._handler),document.removeEventListener(`keydown`,this._docHandler)}},Nr=class{constructor(e){this.editor=e,this._matches=[],this._currentIndex=-1,this._caseSensitive=!1,this._panel=null,this._findInput=null,this._replaceInput=null,this._countEl=null,this._replaceRow=null,this._caseSensitiveBtn=null,this._highlightEl=null,this._scrollHandler=null,this._taHandler=this._onTextareaKeyDown.bind(this),e.usertextarea.addEventListener(`keydown`,this._taHandler)}_onTextareaKeyDown(e){let t=e.ctrlKey||e.metaKey;t&&e.key===`f`?(e.preventDefault(),this.open(!1)):t&&e.key===`h`&&(e.preventDefault(),this.open(!0))}open(e=!1){this._panel||this._buildPanel(),this._panel.hidden=!1,e&&(this._replaceRow.hidden=!1),this._findInput.focus(),this._findInput.select();let t=this.editor.usertextarea.value.substring(this.editor.usertextarea.selectionStart,this.editor.usertextarea.selectionEnd);t&&!t.includes(`
|
|
177
|
-
`)&&(this._findInput.value=t),this._scrollHandler||(this._scrollHandler=()=>this._showMatchHighlight(),this.editor.usertextarea.addEventListener(`scroll`,this._scrollHandler)),this._search()}close(){if(!this._panel)return;this._panel.hidden=!0,this._clearMatchHighlight(),this._scrollHandler&&=(this.editor.usertextarea.removeEventListener(`scroll`,this._scrollHandler),null);let e=this.editor.usertextarea;if(this._currentIndex!==-1&&this._matches.length){let{start:t,end:n}=this._matches[this._currentIndex];e.focus(),e.setSelectionRange(t,n)}else e.focus();this._matches=[],this._currentIndex=-1}_buildPanel(){let e=document.createElement(`div`);e.className=`find-replace-panel fj:absolute fj:top-1 fj:right-1 fj:z-20 fj:me-surface fj:me-surface-outline fj:me-surface-rounded fj:p-1.5 fj:flex fj:flex-col fj:gap-1 fj:shadow-lg`,e.setAttribute(`role`,`search`),e.setAttribute(`aria-label`,this.editor.label(`Find and replace`));let t=document.createElement(`div`);t.className=`fj:flex fj:items-center fj:gap-1`,this._findInput=document.createElement(`input`),this._findInput.type=`text`,this._findInput.placeholder=this.editor.label(`Find`),this._findInput.className=`fj:me-input fj:me-input-xs fj:w-36`,this._findInput.setAttribute(`aria-label`,this.editor.label(`Find`)),this._findInput.addEventListener(`input`,()=>this._search()),this._findInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.shiftKey?this._prev():this._next()),e.key===`Escape`&&(e.preventDefault(),this.close())}),this._countEl=document.createElement(`span`),this._countEl.className=`fj:text-xs fj:opacity-50 fj:whitespace-nowrap fj:min-w-[3.5rem] fj:text-center fj:select-none`,this._countEl.setAttribute(`aria-live`,`polite`);let n=this._iconBtn(`Previous match`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>`);n.addEventListener(`click`,()=>this._prev());let r=this._iconBtn(`Next match`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>`);r.addEventListener(`click`,()=>this._next()),this._caseSensitiveBtn=document.createElement(`button`),this._caseSensitiveBtn.type=`button`,this._caseSensitiveBtn.className=`fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost fj:text-xs fj:font-bold`,this._caseSensitiveBtn.textContent=`Aa`,this._caseSensitiveBtn.setAttribute(`aria-label`,this.editor.label(`Match case`)),this._caseSensitiveBtn.setAttribute(`aria-pressed`,`false`),this._caseSensitiveBtn.title=this.editor.label(`Match case`),this._caseSensitiveBtn.addEventListener(`click`,()=>{this._caseSensitive=!this._caseSensitive,this._caseSensitiveBtn.setAttribute(`aria-pressed`,String(this._caseSensitive)),this._caseSensitiveBtn.classList.toggle(`fj:me-btn-active`,this._caseSensitive),this._search()});let i=document.createElement(`button`);i.type=`button`,i.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,i.textContent=this.editor.label(`Replace`),i.setAttribute(`aria-label`,this.editor.label(`Toggle replace row`)),i.addEventListener(`click`,()=>{this._replaceRow.hidden=!this._replaceRow.hidden,this._replaceRow.hidden||this._replaceInput.focus()});let a=this._iconBtn(`Close`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`);a.addEventListener(`click`,()=>this.close()),t.append(this._findInput,this._countEl,n,r,this._caseSensitiveBtn,i,a),this._replaceRow=document.createElement(`div`),this._replaceRow.className=`fj:flex fj:items-center fj:gap-1`,this._replaceRow.hidden=!0,this._replaceInput=document.createElement(`input`),this._replaceInput.type=`text`,this._replaceInput.placeholder=this.editor.label(`Replace`),this._replaceInput.className=`fj:me-input fj:me-input-xs fj:w-36`,this._replaceInput.setAttribute(`aria-label`,this.editor.label(`Replace with`)),this._replaceInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&this._replace(),e.key===`Escape`&&(e.preventDefault(),this.close())});let o=document.createElement(`button`);o.type=`button`,o.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,o.textContent=this.editor.label(`Replace`),o.addEventListener(`click`,()=>this._replace());let s=document.createElement(`button`);s.type=`button`,s.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,s.textContent=this.editor.label(`All`),s.setAttribute(`aria-label`,this.editor.label(`Replace all`)),s.addEventListener(`click`,()=>this._replaceAll()),this._replaceRow.append(this._replaceInput,o,s),e.append(t,this._replaceRow),this.editor.markdownEditorDiv.appendChild(e),this._panel=e}_iconBtn(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost`,n.setAttribute(`aria-label`,this.editor.label(e)),n.innerHTML=t;let r=n.querySelector(`svg`);return r&&r.setAttribute(`aria-hidden`,`true`),n}_search(){let e=this._findInput?.value??``,t=this.editor.usertextarea.value;if(!e){this._matches=[],this._currentIndex=-1,this._clearMatchHighlight(),this._updateCount();return}let n=this._caseSensitive?t:t.toLowerCase(),r=this._caseSensitive?e:e.toLowerCase();this._matches=[];let i=0;for(;i<=n.length-r.length;){let t=n.indexOf(r,i);if(t===-1)break;this._matches.push({start:t,end:t+e.length}),i=t+1}this._currentIndex=this._matches.length>0?Math.min(Math.max(this._currentIndex,0),this._matches.length-1):-1,this._selectCurrent(),this._updateCount()}_next(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex+1)%this._matches.length,this._selectCurrent(),this._updateCount())}_prev(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex-1+this._matches.length)%this._matches.length,this._selectCurrent(),this._updateCount())}_selectCurrent(){if(this._currentIndex===-1||this._matches.length===0){this._clearMatchHighlight();return}let{start:e}=this._matches[this._currentIndex];this._scrollToMatch(this.editor.usertextarea,e),this._showMatchHighlight()}_scrollToMatch(e,t){let n=parseInt(window.getComputedStyle(e).lineHeight)||20,r=e.value.substring(0,t).split(`
|
|
178
|
-
`).length-1,i=Math.floor(e.clientHeight/n);e.scrollTop=Math.max(0,(r-Math.floor(i/2))*n)}_showMatchHighlight(){if(this._clearMatchHighlight(),this._currentIndex===-1||!this._matches.length)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=window.getComputedStyle(n),i=n.parentElement,a=document.createElement(`div`);Object.assign(a.style,{position:`absolute`,visibility:`hidden`,pointerEvents:`none`,top:`0`,left:`0`,right:`0`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,overflowWrap:`break-word`,font:r.font,lineHeight:r.lineHeight,paddingTop:r.paddingTop,paddingRight:r.paddingRight,paddingBottom:r.paddingBottom,paddingLeft:r.paddingLeft,boxSizing:`border-box`});let o=document.createElement(`span`);o.textContent=n.value.substring(e,t)||``,a.appendChild(document.createTextNode(n.value.substring(0,e))),a.appendChild(o),a.appendChild(document.createTextNode(n.value.substring(t))),i.appendChild(a);try{let e=i.getBoundingClientRect(),t=o.getBoundingClientRect(),r=document.createElement(`div`);Object.assign(r.style,{position:`absolute`,top:t.top-e.top-n.scrollTop+`px`,left:t.left-e.left+`px`,width:Math.max(t.width,2)+`px`,height:t.height+`px`,background:`color-mix(in oklch, var(--color-primary, oklch(0.6 0.2 250)), transparent 55%)`,borderRadius:`2px`,pointerEvents:`none`,zIndex:`2`}),i.appendChild(r),this._highlightEl=r}finally{i.removeChild(a)}}_clearMatchHighlight(){this._highlightEl?.remove(),this._highlightEl=null}_updateCount(){this._countEl&&(this._matches.length===0?this._countEl.textContent=this._findInput?.value?`No results`:``:this._countEl.textContent=`${this._currentIndex+1} of ${this._matches.length}`)}_replace(){if(this._currentIndex===-1)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=this._replaceInput.value;n.value=n.value.substring(0,e)+r+n.value.substring(t),this.editor.render(),this.editor.notifyChange(),this._search()}_replaceAll(){let e=this._findInput?.value;if(!e)return;let t=this._replaceInput.value,n=this.editor.usertextarea,r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=this._caseSensitive?`g`:`gi`;n.value=n.value.replace(new RegExp(r,i),t),this.editor.render(),this.editor.notifyChange(),this._currentIndex=0,this._search()}destroy(){this.editor.usertextarea.removeEventListener(`keydown`,this._taHandler),this._scrollHandler&&this.editor.usertextarea.removeEventListener(`scroll`,this._scrollHandler),this._clearMatchHighlight(),this._panel?.remove()}},Pr=/^https?:\/\/\S+$/i,Fr=class{constructor(e){this.editor=e,this.textarea=e.usertextarea,this._pasteHandler=e=>this._onPaste(e),this._dropHandler=e=>this._onDrop(e),this._dragOverHandler=e=>{this._carriesFiles(e.dataTransfer)&&e.preventDefault()},this.textarea.addEventListener(`paste`,this._pasteHandler),this.textarea.addEventListener(`drop`,this._dropHandler),this.textarea.addEventListener(`dragover`,this._dragOverHandler)}destroy(){this.textarea.removeEventListener(`paste`,this._pasteHandler),this.textarea.removeEventListener(`drop`,this._dropHandler),this.textarea.removeEventListener(`dragover`,this._dragOverHandler)}_carriesFiles(e){return Array.from(e?.types??[]).includes(`Files`)}_imageFiles(e){return Array.from(e?.files??[]).filter(e=>e.type?.startsWith(`image/`))}_onPaste(e){let t=this._imageFiles(e.clipboardData);if(t.length){if(!this.editor.imageUpload){console.warn(`[MarkdownEditor] An image was pasted but no upload endpoint is configured. Add { image: { fileInput: { uploadUrl: "..." } } } to the toolbar to enable it.`);return}e.preventDefault(),this._uploadAll(t);return}let n=e.clipboardData?.getData(`text/plain`)?.trim(),{selectionStart:r,selectionEnd:i}=this.textarea;if(n&&i>r&&Pr.test(n)){e.preventDefault();let t=`[${this.textarea.value.slice(r,i)}](${n})`;this.editor.insertText(t,t.length,0)}}_onDrop(e){if(!this._carriesFiles(e.dataTransfer))return;e.preventDefault();let t=this._imageFiles(e.dataTransfer);t.length&&(this.editor.imageUpload?this._uploadAll(t):console.warn(`[MarkdownEditor] An image was dropped but no upload endpoint is configured. Add { image: { fileInput: { uploadUrl: "..." } } } to the toolbar to enable it.`))}async _uploadAll(e){for(let t of e){let e=`![${this.editor.label(`Uploading...`)}]()`;this.editor.insertText(e,e.length,0);try{let{path:n,alt:r}=await Hn(t,this.editor.imageUpload);this._replace(e,``)}catch(t){this._replace(e,`![${this.editor.label(`Upload failed`)}]()`),console.error(`[MarkdownEditor] Image upload failed.`,t)}}}_replace(e,t){let n=this.textarea,r=n.value.indexOf(e);if(r===-1)return;n.value=n.value.slice(0,r)+t+n.value.slice(r+e.length);let i=r+t.length;n.setSelectionRange(i,i),this.editor.render(),this.editor.notifyChange()}},Ir=new st({breaks:!0}),Lr=class e{constructor(e,t={}){this.usertextarea=typeof e==`string`?document.querySelector(e):e,this.options=t,this.mode=t.mode||`plain`,this.preview=!this.options.toolbar||this.options.toolbar.includes(`preview`),this.footerOptions=this._parseFooterOptions(t.footer),this.variables=this._parseVariables(t.toolbar),this.imageUpload=this._parseImageUpload(t.toolbar),this.previewTimer=null,this.init(),this.undoRedoManager=new Dr(this),this.listManager=new kr(this),this.indentManager=new Or(this),this.shortcutManager=new Mr(this),this.findReplace=new Nr(this),this.pasteManager=new Fr(this),this._warnIfStylesheetMissing(),this._warnIfLocaleIsACode()}_warnIfLocaleIsACode(){let e=this.options.locale;typeof e==`string`&&console.error(`[MarkdownEditor] locale: '${e}' has no effect. It takes the strings, not a code:\n import ${/^[a-z]{2}$/i.test(e)?e:`strings`} from 'markdown-text-editor/locale/${e}.js'\n new MarkdownEditor(el, { locale: ${/^[a-z]{2}$/i.test(e)?e:`strings`} })`)}_warnIfStylesheetMissing(){e._cssWarned||this.editorContainer?.isConnected&&(getComputedStyle(this.editorContainer).getPropertyValue(`--mte-css`).trim()||(e._cssWarned=!0,console.error(`[MarkdownEditor] Stylesheet not loaded, so the editor will look unstyled.
|
|
176
|
+
`+a,this.textarea.setSelectionRange(r+1,r+1),this.editor.render(),this.editor.notifyChange();return}let c=null;if(a?c=`${a[1]}${parseInt(a[2])+1}. `:o?c=`${o[1]}${o[2]}[ ] `:s&&(c=`${s[1]}${s[2]}`),c){e.preventDefault();let r=`\n${c}`,i=n.substring(0,t),a=n.substring(t);this.textarea.value=i+r+a;let o=t+r.length;this.textarea.setSelectionRange(o,o),this.editor.render(),this.editor.notifyChange()}}},Ar=[{key:`b`,ctrl:!0,shift:!1,ToolClass:Mn,label:`Ctrl+B`,btnClass:`bold-btn`},{key:`i`,ctrl:!0,shift:!1,ToolClass:Nn,label:`Ctrl+I`,btnClass:`italic-btn`},{key:`k`,ctrl:!0,shift:!1,ToolClass:zn,label:`Ctrl+K`,btnClass:`link-btn`},{key:"`",ctrl:!0,shift:!1,ToolClass:Jn,label:"Ctrl+`",btnClass:`code-btn`},{key:`s`,ctrl:!0,shift:!0,ToolClass:Pn,label:`Ctrl+Shift+S`,btnClass:`strikethrough-btn`},{key:`l`,ctrl:!0,shift:!1,ToolClass:Fn,label:`Ctrl+L`,btnClass:`ul-btn`}];function jr(e){let t=String(e).split(`+`).map(e=>e.trim().toLowerCase()),n=t.pop();return n?{key:n,ctrl:t.includes(`ctrl`)||t.includes(`cmd`)||t.includes(`meta`),shift:t.includes(`shift`),alt:t.includes(`alt`)}:null}var Mr=class{constructor(e){this.editor=e,this.toolShortcuts=(e.toolbarInstance?.tools??[]).filter(e=>e.shortcut).map(e=>({tool:e,combo:jr(e.shortcut)})).filter(e=>e.combo);let t=(e.toolbarInstance?.tools??[]).find(e=>e instanceof $);this.headingLevels=t?.levels??[1,2,3,4,5,6],this._handler=this._onKeyDown.bind(this),this._docHandler=this._onDocKeyDown.bind(this),e.usertextarea.addEventListener(`keydown`,this._handler),document.addEventListener(`keydown`,this._docHandler),this._updateTooltips()}_onKeyDown(e){let t=e.ctrlKey||e.metaKey,n=e.shiftKey,r=e.key.toLowerCase();if(t&&n&&r===`f`)e.preventDefault(),this.editor.editorContainer.querySelector(`.preview-btn`)?.click();else if(t&&!n&&[`1`,`2`,`3`].includes(e.key)&&this.headingLevels.includes(parseInt(e.key)))e.preventDefault(),new $(this.editor).applyHeading(parseInt(e.key));else{for(let{tool:i,combo:a}of this.toolShortcuts)if(r===a.key&&t===a.ctrl&&n===a.shift&&e.altKey===a.alt){e.preventDefault(),i.applySyntax(e);return}for(let i of Ar)if(r===i.key&&t===i.ctrl&&n===i.shift){e.preventDefault(),new i.ToolClass(this.editor).applySyntax(e);return}}}_onDocKeyDown(e){if(e.key===`F11`){let t=this.editor.editorContainer.contains(document.activeElement),n=this.editor.editorContainer.classList.contains(`is-fullscreen`);(t||n)&&(e.preventDefault(),this.editor.editorContainer.querySelector(`.preview-btn`)?.click())}}_updateTooltips(){for(let{btnClass:e,label:t}of Ar){let n=this.editor.editorContainer.querySelector(`.${e}`);n&&(n.title+=` (${t})`)}let e=this.editor.editorContainer.querySelector(`.heading-btn`),t=this.headingLevels.filter(e=>e<=3);e&&t.length&&(e.title+=` (Ctrl+${t.join(`/`)})`);let n=this.editor.editorContainer.querySelector(`.preview-btn`);n&&(n.title+=` (F11)`);for(let{tool:e}of this.toolShortcuts)e.button&&(e.button.title+=` (${e.shortcut})`)}destroy(){this.editor.usertextarea.removeEventListener(`keydown`,this._handler),document.removeEventListener(`keydown`,this._docHandler)}},Nr=class{constructor(e){this.editor=e,this._matches=[],this._currentIndex=-1,this._caseSensitive=!1,this._panel=null,this._findInput=null,this._replaceInput=null,this._countEl=null,this._replaceRow=null,this._caseSensitiveBtn=null,this._highlightEl=null,this._matchTop=null,this._matchHeight=0,this._scrollHandler=null,this._taHandler=this._onTextareaKeyDown.bind(this),e.usertextarea.addEventListener(`keydown`,this._taHandler)}_onTextareaKeyDown(e){let t=e.ctrlKey||e.metaKey;t&&e.key===`f`?(e.preventDefault(),this.open(!1)):t&&e.key===`h`&&(e.preventDefault(),this.open(!0))}open(e=!1){this._panel||this._buildPanel(),this._panel.hidden=!1,e&&(this._replaceRow.hidden=!1),this._findInput.focus(),this._findInput.select();let t=this.editor.usertextarea.value.substring(this.editor.usertextarea.selectionStart,this.editor.usertextarea.selectionEnd);t&&!t.includes(`
|
|
177
|
+
`)&&(this._findInput.value=t),this._scrollHandler||(this._scrollHandler=()=>this._showMatchHighlight(),this.editor.usertextarea.addEventListener(`scroll`,this._scrollHandler)),this._search()}close(){if(!this._panel)return;this._panel.hidden=!0,this._clearMatchHighlight(),this._scrollHandler&&=(this.editor.usertextarea.removeEventListener(`scroll`,this._scrollHandler),null);let e=this.editor.usertextarea;if(this._currentIndex!==-1&&this._matches.length){let{start:t,end:n}=this._matches[this._currentIndex];e.focus(),e.setSelectionRange(t,n)}else e.focus();this._matches=[],this._currentIndex=-1}_buildPanel(){let e=document.createElement(`div`);e.className=`find-replace-panel fj:absolute fj:top-1 fj:right-1 fj:z-20 fj:me-surface fj:me-surface-outline fj:me-surface-rounded fj:p-1.5 fj:flex fj:flex-col fj:gap-1 fj:shadow-lg`,e.setAttribute(`role`,`search`),e.setAttribute(`aria-label`,this.editor.label(`Find and replace`));let t=document.createElement(`div`);t.className=`fj:flex fj:items-center fj:gap-1`,this._findInput=document.createElement(`input`),this._findInput.type=`text`,this._findInput.placeholder=this.editor.label(`Find`),this._findInput.className=`fj:me-input fj:me-input-xs fj:w-36`,this._findInput.setAttribute(`aria-label`,this.editor.label(`Find`)),this._findInput.addEventListener(`input`,()=>this._search()),this._findInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.shiftKey?this._prev():this._next()),e.key===`Escape`&&(e.preventDefault(),this.close())}),this._countEl=document.createElement(`span`),this._countEl.className=`fj:text-xs fj:opacity-50 fj:whitespace-nowrap fj:min-w-[3.5rem] fj:text-center fj:select-none`,this._countEl.setAttribute(`aria-live`,`polite`);let n=this._iconBtn(`Previous match`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m18 15-6-6-6 6"/></svg>`);n.addEventListener(`click`,()=>this._prev());let r=this._iconBtn(`Next match`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>`);r.addEventListener(`click`,()=>this._next()),this._caseSensitiveBtn=document.createElement(`button`),this._caseSensitiveBtn.type=`button`,this._caseSensitiveBtn.className=`fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost fj:text-xs fj:font-bold`,this._caseSensitiveBtn.textContent=`Aa`,this._caseSensitiveBtn.setAttribute(`aria-label`,this.editor.label(`Match case`)),this._caseSensitiveBtn.setAttribute(`aria-pressed`,`false`),this._caseSensitiveBtn.title=this.editor.label(`Match case`),this._caseSensitiveBtn.addEventListener(`click`,()=>{this._caseSensitive=!this._caseSensitive,this._caseSensitiveBtn.setAttribute(`aria-pressed`,String(this._caseSensitive)),this._caseSensitiveBtn.classList.toggle(`fj:me-btn-active`,this._caseSensitive),this._search()});let i=document.createElement(`button`);i.type=`button`,i.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,i.textContent=this.editor.label(`Replace`),i.setAttribute(`aria-label`,this.editor.label(`Toggle replace row`)),i.addEventListener(`click`,()=>{this._replaceRow.hidden=!this._replaceRow.hidden,this._replaceRow.hidden||this._replaceInput.focus()});let a=this._iconBtn(`Close`,`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`);a.addEventListener(`click`,()=>this.close()),t.append(this._findInput,this._countEl,n,r,this._caseSensitiveBtn,i,a),this._replaceRow=document.createElement(`div`),this._replaceRow.className=`fj:flex fj:items-center fj:gap-1`,this._replaceRow.hidden=!0,this._replaceInput=document.createElement(`input`),this._replaceInput.type=`text`,this._replaceInput.placeholder=this.editor.label(`Replace`),this._replaceInput.className=`fj:me-input fj:me-input-xs fj:w-36`,this._replaceInput.setAttribute(`aria-label`,this.editor.label(`Replace with`)),this._replaceInput.addEventListener(`keydown`,e=>{e.key===`Enter`&&this._replace(),e.key===`Escape`&&(e.preventDefault(),this.close())});let o=document.createElement(`button`);o.type=`button`,o.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,o.textContent=this.editor.label(`Replace`),o.addEventListener(`click`,()=>this._replace());let s=document.createElement(`button`);s.type=`button`,s.className=`fj:me-btn fj:me-btn-xs fj:me-btn-ghost fj:text-xs fj:px-1.5`,s.textContent=this.editor.label(`All`),s.setAttribute(`aria-label`,this.editor.label(`Replace all`)),s.addEventListener(`click`,()=>this._replaceAll()),this._replaceRow.append(this._replaceInput,o,s),e.append(t,this._replaceRow),this.editor.markdownEditorDiv.appendChild(e),this._panel=e}_iconBtn(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`fj:me-btn fj:me-btn-xs fj:me-btn-square fj:me-btn-ghost`,n.setAttribute(`aria-label`,this.editor.label(e)),n.innerHTML=t;let r=n.querySelector(`svg`);return r&&r.setAttribute(`aria-hidden`,`true`),n}_search(){let e=this._findInput?.value??``,t=this.editor.usertextarea.value;if(!e){this._matches=[],this._currentIndex=-1,this._clearMatchHighlight(),this._updateCount();return}let n=this._caseSensitive?t:t.toLowerCase(),r=this._caseSensitive?e:e.toLowerCase();this._matches=[];let i=0;for(;i<=n.length-r.length;){let t=n.indexOf(r,i);if(t===-1)break;this._matches.push({start:t,end:t+e.length}),i=t+1}this._currentIndex=this._matches.length>0?Math.min(Math.max(this._currentIndex,0),this._matches.length-1):-1,this._selectCurrent(),this._updateCount()}_next(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex+1)%this._matches.length,this._selectCurrent(),this._updateCount())}_prev(){this._matches.length!==0&&(this._currentIndex=(this._currentIndex-1+this._matches.length)%this._matches.length,this._selectCurrent(),this._updateCount())}_selectCurrent(){this._currentIndex===-1||this._matches.length===0?this._clearMatchHighlight():(this._showMatchHighlight(),this._scrollMatchIntoView())}_scrollMatchIntoView(){let e=this.editor.usertextarea;if(this._matchTop===null||this._matchHeight<=0)return;let t=e.clientHeight,n=e.scrollTop,r=this._matchHeight,i=n;this._matchTop-r<n?i=this._matchTop-r:this._matchTop+this._matchHeight+r>n+t&&(i=this._matchTop+this._matchHeight+r-t),i!==n&&(e.scrollTop=Math.max(0,i),this._highlightEl&&(this._highlightEl.style.top=this._matchTop-e.scrollTop+`px`))}_showMatchHighlight(){if(this._clearMatchHighlight(),this._currentIndex===-1||!this._matches.length)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=window.getComputedStyle(n),i=n.parentElement,a=document.createElement(`div`);Object.assign(a.style,{position:`absolute`,visibility:`hidden`,pointerEvents:`none`,top:`0`,left:`0`,width:n.clientWidth+`px`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,overflowWrap:`break-word`,font:r.font,lineHeight:r.lineHeight,paddingTop:r.paddingTop,paddingRight:r.paddingRight,paddingBottom:r.paddingBottom,paddingLeft:r.paddingLeft,boxSizing:`border-box`});let o=document.createElement(`span`);o.textContent=n.value.substring(e,t)||``,a.appendChild(document.createTextNode(n.value.substring(0,e))),a.appendChild(o),a.appendChild(document.createTextNode(n.value.substring(t))),i.appendChild(a);try{let e=i.getBoundingClientRect(),t=o.getBoundingClientRect();this._matchTop=t.top-e.top,this._matchHeight=t.height;let r=document.createElement(`div`);Object.assign(r.style,{position:`absolute`,top:t.top-e.top-n.scrollTop+`px`,left:t.left-e.left+`px`,width:Math.max(t.width,2)+`px`,height:t.height+`px`,background:`color-mix(in oklch, var(--color-primary, oklch(0.6 0.2 250)), transparent 55%)`,borderRadius:`2px`,pointerEvents:`none`,zIndex:`2`}),i.appendChild(r),this._highlightEl=r}finally{i.removeChild(a)}}_clearMatchHighlight(){this._highlightEl?.remove(),this._highlightEl=null,this._matchTop=null}_updateCount(){this._countEl&&(this._matches.length===0?this._countEl.textContent=this._findInput?.value?`No results`:``:this._countEl.textContent=`${this._currentIndex+1} of ${this._matches.length}`)}_replace(){if(this._currentIndex===-1)return;let{start:e,end:t}=this._matches[this._currentIndex],n=this.editor.usertextarea,r=this._replaceInput.value;n.value=n.value.substring(0,e)+r+n.value.substring(t),this.editor.render(),this.editor.notifyChange(),this._search()}_replaceAll(){let e=this._findInput?.value;if(!e)return;let t=this._replaceInput.value,n=this.editor.usertextarea,r=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=this._caseSensitive?`g`:`gi`;n.value=n.value.replace(new RegExp(r,i),t),this.editor.render(),this.editor.notifyChange(),this._currentIndex=0,this._search()}destroy(){this.editor.usertextarea.removeEventListener(`keydown`,this._taHandler),this._scrollHandler&&this.editor.usertextarea.removeEventListener(`scroll`,this._scrollHandler),this._clearMatchHighlight(),this._panel?.remove()}},Pr=/^https?:\/\/\S+$/i,Fr=class{constructor(e){this.editor=e,this.textarea=e.usertextarea,this._pasteHandler=e=>this._onPaste(e),this._dropHandler=e=>this._onDrop(e),this._dragOverHandler=e=>{this._carriesFiles(e.dataTransfer)&&e.preventDefault()},this.textarea.addEventListener(`paste`,this._pasteHandler),this.textarea.addEventListener(`drop`,this._dropHandler),this.textarea.addEventListener(`dragover`,this._dragOverHandler)}destroy(){this.textarea.removeEventListener(`paste`,this._pasteHandler),this.textarea.removeEventListener(`drop`,this._dropHandler),this.textarea.removeEventListener(`dragover`,this._dragOverHandler)}_carriesFiles(e){return Array.from(e?.types??[]).includes(`Files`)}_imageFiles(e){return Array.from(e?.files??[]).filter(e=>e.type?.startsWith(`image/`))}_onPaste(e){let t=this._imageFiles(e.clipboardData);if(t.length){if(!this.editor.imageUpload){console.warn(`[MarkdownEditor] An image was pasted but no upload endpoint is configured. Add { image: { fileInput: { uploadUrl: "..." } } } to the toolbar to enable it.`);return}e.preventDefault(),this._uploadAll(t);return}let n=e.clipboardData?.getData(`text/plain`)?.trim(),{selectionStart:r,selectionEnd:i}=this.textarea;if(n&&i>r&&Pr.test(n)){e.preventDefault();let t=`[${this.textarea.value.slice(r,i)}](${n})`;this.editor.insertText(t,t.length,0)}}_onDrop(e){if(!this._carriesFiles(e.dataTransfer))return;e.preventDefault();let t=this._imageFiles(e.dataTransfer);t.length&&(this.editor.imageUpload?this._uploadAll(t):console.warn(`[MarkdownEditor] An image was dropped but no upload endpoint is configured. Add { image: { fileInput: { uploadUrl: "..." } } } to the toolbar to enable it.`))}async _uploadAll(e){for(let t of e){let e=`![${this.editor.label(`Uploading...`)}]()`;this.editor.insertText(e,e.length,0);try{let{path:n,alt:r}=await Hn(t,this.editor.imageUpload);this._replace(e,``)}catch(t){this._replace(e,`![${this.editor.label(`Upload failed`)}]()`),console.error(`[MarkdownEditor] Image upload failed.`,t)}}}_replace(e,t){let n=this.textarea,r=n.value.indexOf(e);if(r===-1)return;n.value=n.value.slice(0,r)+t+n.value.slice(r+e.length);let i=r+t.length;n.setSelectionRange(i,i),this.editor.render(),this.editor.notifyChange()}},Ir=new st({breaks:!0}),Lr=class e{constructor(e,t={}){this.usertextarea=typeof e==`string`?document.querySelector(e):e,this.options=t,this.mode=t.mode||`plain`,this.preview=!this.options.toolbar||this.options.toolbar.includes(`preview`),this.footerOptions=this._parseFooterOptions(t.footer),this.variables=this._parseVariables(t.toolbar),this.imageUpload=this._parseImageUpload(t.toolbar),this.previewTimer=null,this.init(),this.undoRedoManager=new Dr(this),this.listManager=new kr(this),this.indentManager=new Or(this),this.shortcutManager=new Mr(this),this.findReplace=new Nr(this),this.pasteManager=new Fr(this),this._warnIfStylesheetMissing(),this._warnIfLocaleIsACode()}_warnIfLocaleIsACode(){let e=this.options.locale;typeof e==`string`&&console.error(`[MarkdownEditor] locale: '${e}' has no effect. It takes the strings, not a code:\n import ${/^[a-z]{2}$/i.test(e)?e:`strings`} from 'markdown-text-editor/locale/${e}.js'\n new MarkdownEditor(el, { locale: ${/^[a-z]{2}$/i.test(e)?e:`strings`} })`)}_warnIfStylesheetMissing(){e._cssWarned||this.editorContainer?.isConnected&&(getComputedStyle(this.editorContainer).getPropertyValue(`--mte-css`).trim()||(e._cssWarned=!0,console.error(`[MarkdownEditor] Stylesheet not loaded, so the editor will look unstyled.
|
|
179
178
|
Bundlers: import 'markdown-text-editor/style.css'
|
|
180
179
|
Browsers: <link rel="stylesheet" href=".../dist/markdown-text-editor.css">`)))}label(e){return(this.options.locale??this.options.labels)?.[e]??e}_parseImageUpload(e){let t=(Array.isArray(e)?e:[]).find(e=>e&&typeof e==`object`&&e.image)?.image?.fileInput;return t?.uploadUrl?t:null}_parseVariables(e){let t=(Array.isArray(e)?e:[]).find(e=>e&&typeof e==`object`&&Array.isArray(e.variables));return t?t.variables:[]}_parseFooterOptions(e){if(e===!1)return null;let t=e??{};return{line:t.line!==!1,col:t.col!==!1,chars:t.chars!==!1,words:t.words===!0}}init(){this.createEditor(),this.addToolbar(),this.addFooter(),this._toolbarH=this.editorContainer.querySelector(`.toolbar`)?.offsetHeight??0,this._footerH=this.editorContainer.querySelector(`.editor-footer`)?.offsetHeight??0,this._autoGrow()}createEditor(){this.isTextareaValid()&&(this.applyDefaultAttributes(),this.buildEditorLayout(),this.addInputListener(),this.render())}isTextareaValid(){return this.usertextarea.tagName===`TEXTAREA`}applyDefaultAttributes(){this.usertextarea.id&&document.querySelector(`label[for="${this.usertextarea.id}"]`)||this.usertextarea.getAttribute(`aria-label`)||this.usertextarea.getAttribute(`aria-labelledby`)||(this.usertextarea.setAttribute(`aria-label`,this.options.label||`Markdown editor`),this._addedAriaLabel=!0),this.usertextarea.classList.add(`editor-textarea`,`fj:focus:ring-0`,`fj:focus:outline-0`,`fj:border-0`,`fj:border-base-soft`,`fj:px-4`,`fj:py-2`,`fj:max-w-full`,`fj:w-full`,`fj:h-full`,`fj:bg-transparent`,`fj:outline-0`,`fj:appearance-none`,`fj:overflow-y-auto`,`fj:resize-none`),this.usertextarea.hasAttribute(`placeholder`)||(this.usertextarea.placeholder=this.options.placeholder||`Write your markdown...`)}buildEditorLayout(){this.editorContainer=document.createElement(`div`),this.editorContainer.className=`
|
|
181
180
|
markdown-editor-wrapper
|
|
@@ -220,7 +219,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
220
219
|
fj:box-border
|
|
221
220
|
fj:relative
|
|
222
221
|
fj:z-10
|
|
223
|
-
`,e.appendChild(this.displayLayer)),e.appendChild(this.usertextarea),this.markdownEditorDiv.appendChild(e)}addPreviewWrapper(){let e=new ir(this.markdownEditorDiv);this.previewContent=e.getPreviewContent()}addInputListener(){this._inputHandler=()=>{this._autoGrow(),this.renderHybrid(),this.debouncedPreview(),this.notifyChange()},this._scrollHandler=()=>{this._scrollRaf||=requestAnimationFrame(()=>{
|
|
222
|
+
`,e.appendChild(this.displayLayer)),e.appendChild(this.usertextarea),this.markdownEditorDiv.appendChild(e)}addPreviewWrapper(){let e=new ir(this.markdownEditorDiv);this.previewContent=e.getPreviewContent()}addInputListener(){this._inputHandler=()=>{this._autoGrow(),this.renderHybrid(),this.debouncedPreview(),this.notifyChange()},this._scrollHandler=()=>{this._scrollRaf||=requestAnimationFrame(()=>{this._scrollRaf=null,this.mode===`hybrid`&&(this.displayLayer.scrollTop=this.usertextarea.scrollTop,this.displayLayer.scrollLeft=this.usertextarea.scrollLeft),this.preview&&this.previewContent&&this._syncPreviewScroll()})},this.usertextarea.addEventListener(`input`,this._inputHandler),this.usertextarea.addEventListener(`scroll`,this._scrollHandler)}debouncedPreview(){this.preview&&(clearTimeout(this.previewTimer),this.previewTimer=setTimeout(()=>{let e=this.previewContent.scrollTop;this.previewContent.innerHTML=this._renderMarkdown(this.usertextarea.value),this.wirePreviewCheckboxes(),this._syncPreviewScroll()||(this.previewContent.scrollTop=e)},150))}_syncPreviewScroll(){if(!this.preview||!this.previewContent)return!1;let e=this.usertextarea,t=e.scrollHeight-e.clientHeight;if(t<=0)return!1;let n=e.scrollTop/t,r=this.previewContent.scrollHeight-this.previewContent.clientHeight;return this.previewContent.scrollTop=n*r,!0}renderMarkdown(e){return this._renderMarkdown(e)}createToolbar(e,t=[`bold`,`italic`,`strikethrough`]){let n=Object.create(this);return n.usertextarea=e,n.render=()=>{},n.notifyChange=()=>{},n.insertText=(t,n=0,r=0)=>{let{selectionStart:i,selectionEnd:a,value:o}=e,s=e.scrollTop;e.value=o.slice(0,i)+t+o.slice(a),e.focus(),e.setSelectionRange(i+n,i+t.length-r),e.scrollTop=s},new rr(n,t,{standalone:!0}).toolbar}_renderMarkdown(e){let t=this.options.renderer??(e=>Ir.parse(e)),n=this.options.sanitizer??(e=>jn.sanitize(e)),r=$n(e,this.variables),i=t(r);return this.options.renderer&&!this._taskListWarned&&/^\s*[-*] \[[ xX]\] /m.test(r)&&!/type=["']?checkbox/.test(i)&&(this._taskListWarned=!0,console.warn(`[MarkdownEditor] Task list syntax found, but the custom renderer emitted no checkboxes. Clickable checkboxes in the preview need a task-list plugin, e.g. markdown-it-task-lists.`)),n(i)}wirePreviewCheckboxes(){this.previewContent.querySelectorAll(`input[type="checkbox"]`).forEach((e,t)=>{e.removeAttribute(`disabled`),e.addEventListener(`click`,n=>{n.preventDefault();let r=this.usertextarea.value.split(`
|
|
224
223
|
`),i=0;for(let n=0;n<r.length;n++)if(/^(\s*)([-*] \[[ xX]\] )/.test(r[n])){if(i===t){e.checked?r[n]=r[n].replace(/\[ \]/,`[x]`):r[n]=r[n].replace(/\[[xX]\]/,`[ ]`);break}i++}this.usertextarea.value=r.join(`
|
|
225
224
|
`),this.render(),this.notifyChange()})})}addFooter(){if(!this.footerOptions)return;let{line:e,col:t,chars:n,words:r}=this.footerOptions;(e||t||n||r)&&(this.footer=new ar(this.editorContainer,this.footerOptions,e=>this.label(e)),this.footer.update(this.usertextarea),this._footerUpdate=()=>this.footer.update(this.usertextarea),this.usertextarea.addEventListener(`input`,this._footerUpdate),this.usertextarea.addEventListener(`click`,this._footerUpdate),this.usertextarea.addEventListener(`keyup`,this._footerUpdate),this.usertextarea.addEventListener(`focus`,this._footerUpdate))}addToolbar(){this.toolbarInstance=new rr(this,this.options.toolbar||[`undo`,`redo`,`heading`,`blockquote`,`ul`,`ol`,`checklist`,`outdent`,`indent`,`bold`,`italic`,`strikethrough`,`code`,`codeblock`,`hr`,`table`,`link`,`image`,`preview`])}insertText(e,t=0,n=0){let{selectionStart:r,selectionEnd:i}=this.usertextarea,a=this.usertextarea.value,o=this.usertextarea.scrollTop;this.usertextarea.value=`${a.substring(0,r)}${e}${a.substring(i)}`,this.usertextarea.focus(),this.usertextarea.setSelectionRange(r+t,r+e.length-n),this.render(),this.notifyChange(),this.restoreScroll(o)}restoreScroll(e){this.usertextarea.scrollTop=e}scrollToView(){}_highlight(e){let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);return t=t.replace(/```(\w+)?\n([\s\S]*?)```/g,'<span class="fj:opacity-30">```$1</span>\n$2<span class="fj:opacity-30">```</span>').replace(/`([^`\n]+)`/g,'<span class="fj:opacity-40">`</span><span class="fj:text-accent">$1</span><span class="fj:opacity-40">`</span>').replace(/^(#+ )(.*)$/gm,`<span class="fj:text-primary"><span class="fj:opacity-40">$1</span><span class="faux-bold">$2</span></span>`).replace(/\*\*(.*?)\*\*/g,`<span class="fj:text-secondary"><span class="fj:opacity-40">**</span><span class="faux-bold">$1</span><span class="fj:opacity-40">**</span></span>`).replace(/^([\s]*)([\-\*] |[\d]+\. |\[[\s xX]\] )(.*)$/gm,`$1<span class="fj:text-primary">$2</span>$3`).replace(/(\*|_)(.*?)\1/g,`<span class="fj:text-accent"><span class="fj:opacity-40">$1</span>$2<span class="fj:opacity-40">$1</span></span>`).replace(/~~(.*?)~~/g,`<span class="fj:line-through fj:opacity-70"><span class="fj:opacity-40">~~</span>$1<span class="fj:opacity-40">~~</span></span>`).replace(/(?<!~)(~)([^~]+)\1(?!~)/g,`<span class="fj:line-through fj:opacity-70"><span class="fj:opacity-40">$1</span>$2<span class="fj:opacity-40">$1</span></span>`).replace(/(!?\[)(.*?)(\]\()(.*?)(\))/g,`<span class="fj:opacity-40">$1</span><span class="fj:text-primary">$2</span><span class="fj:opacity-40">$3</span><span class="fj:underline fj:opacity-50">$4</span><span class="fj:opacity-50">$5</span>`),e.endsWith(`
|
|
226
225
|
`)&&(t+=` `),t}renderHybrid(){if(this.mode!==`hybrid`)return;let e=this.usertextarea.value;if(e===this._lastRaw)return;this._lastRaw=e;let t=this._highlight(e).split(`
|