medium-proeditor
Version:
A powerful & customizable Medium-style rich text editor
1 lines • 118 kB
JavaScript
import{S as e,T as t,N as r,F as n,a as s,D as i,b as o,P as a,c as l,M as c,d,e as h,R as u,f as p,l as f,g as m,n as g,s as v,h as y,i as b,j as w,k as E,A as k,m as C,o as A,p as M,q as x,r as N,t as S,u as I,v as T,w as _,x as O,y as D,z as q,B as L,C as R,E as P,G as H,H as z,I as B,J as $,K as V,L as U,O as j,Q as F,U as W,V as G,W as K,X as J,Y as Z,Z as Q,_ as Y,$ as X,a0 as ee,a1 as te,a2 as re,a3 as ne,a4 as se,a5 as ie,a6 as oe,a7 as ae}from"./index-45a1b37e.js";function le(e=0,t=0,r=0){return Math.min(Math.max(e,t),r)}function ce(r,n=null){if(!n)return null;const s=e.atStart(r),i=e.atEnd(r);if("start"===n||!0===n)return s;if("end"===n)return i;const o=s.from,a=i.to;return"all"===n?t.create(r,le(0,o,a),le(r.content.size,o,a)):t.create(r,le(n,o,a),le(n,o,a))}const de=e=>{const t=e.childNodes;for(let r=t.length-1;r>=0;r-=1){const n=t[r];3===n.nodeType&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?e.removeChild(n):1===n.nodeType&&de(n)}return e};function he(e){const t=`<body>${e}</body>`,r=(new window.DOMParser).parseFromString(t,"text/html").body;return de(r)}function ue(e,t,o){if(e instanceof r||e instanceof n)return e;const a={slice:!0,parseOptions:{},...o},l="string"==typeof e;if("object"==typeof e&&null!==e)try{if(Array.isArray(e)&&e.length>0)return n.fromArray(e.map((e=>t.nodeFromJSON(e))));const r=t.nodeFromJSON(e);return a.errorOnInvalidContent&&r.check(),r}catch(r){if(a.errorOnInvalidContent)throw new Error("[medium-proEditor error]: Invalid JSON content",{cause:r});return console.warn("[medium-proEditor warn]: Invalid content.","Passed value:",e,"Error:",r),ue("",t,a)}if(l){if(a.errorOnInvalidContent){let r=!1,n="";const o=new s({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__medium__proeditor__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(r=!0,n="string"==typeof e?e:e.outerHTML,null)}]}})});if(a.slice?i.fromSchema(o).parseSlice(he(e),a.parseOptions):i.fromSchema(o).parse(he(e),a.parseOptions),a.errorOnInvalidContent&&r)throw new Error("[medium-proEditor error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${n}`)})}const r=i.fromSchema(t);return a.slice?r.parseSlice(he(e),a.parseOptions).content:r.parse(he(e),a.parseOptions)}return ue("",t,a)}function pe(e,t,r={},n={}){return ue(e,t,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}function fe(e,t){const r=o.fromSchema(t).serializeFragment(e),n=document.implementation.createHTMLDocument().createElement("div");return n.appendChild(r),n.innerHTML}function me(e,t){return function(e,t,r){const{from:n,to:s}=t,{blockSeparator:i="\n\n",textSerializers:o={}}=r||{};let a="";return e.nodesBetween(n,s,((e,r,l,c)=>{e.isBlock&&r>n&&(a+=i);const d=o?.[e.type.name];if(d)return l&&(a+=d({node:e,pos:r,parent:l,index:c,range:t})),!1;e.isText&&(a+=e?.text?.slice(Math.max(n,r)-r,s-r))})),a}(e,{from:0,to:e.content.size},t)}function ge(e,{checkChildren:t=!0,ignoreWhitespace:r=!1}={}){if(r){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(e.text??"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){for(let n=0;n<e.content.childCount;n++){if(!ge(e.content.child(n),{ignoreWhitespace:r,checkChildren:t}))return!1}return!0}return!1}const ve={addMediaPlus:'<span class="svgIcon svgIcon--25px svgIcon--addMediaPlus"><svg class=svgIcon-use height=25 width=25><path d="M20 12h-7V5h-1v7H5v1h7v7h1v-7h7"fill-rule=evenodd></path></svg></span>',addMediaImageInline:'<span class="svgIcon svgIcon--33px svgIcon--addMediaImageInline"><svg class=svgIcon-use fill=none height=32 width=32><path clip-rule=evenodd d="M19 17a2 2 0 100-4 2 2 0 000 4zm0-1a1 1 0 100-2 1 1 0 000 2z"fill=#1A8917 fill-rule=evenodd></path><path clip-rule=evenodd d="M10 10h12a2 2 0 012 2v8a2 2 0 01-2 2H10a2 2 0 01-2-2v-8a2 2 0 012-2zm0 1a1 1 0 00-1 1v4.293l2.646-2.647a.5.5 0 01.708 0L19.707 21H22a1 1 0 001-1v-8a1 1 0 00-1-1H10zm8.293 10L12 14.707l-3 3V20a1 1 0 001 1h8.293z"fill=#1A8917 fill-rule=evenodd></path><rect height=31 rx=15.5 stroke=#1A8917 width=31 x=.5 y=.5></rect></svg></span>',addMediaUnsplashInline:'<span class="svgIcon svgIcon--33px svgIcon--addMediaUnsplashInline"><svg class=svgIcon-use fill=none height=32 width=32><path d="M18.224 15.313H22V22H10v-6.687h3.776v3.337h4.434v-3.336h.014zm0-5.313h-4.448v3.35h4.434V10h.014z"fill=#1A8917></path><rect height=31 rx=15.5 stroke=#1A8917 width=31 x=.5 y=.5></rect></svg></span>',addMediaVideoInline:'<span class="svgIcon svgIcon--33px svgIcon--addMediaVideoInline"><svg class=svgIcon-use fill=none height=32 width=32><rect height=11.522 rx=1.5 stroke=#1A8917 width=15 x=8.5 y=10.761></rect><path d="M19.5 16.522l-5.25 3.614v-7.229l5.25 3.615z"stroke=#1A8917 stroke-linejoin=round></path><rect height=31 rx=15.5 stroke=#1A8917 width=31 x=.5 y=.5></rect></svg></span>',addMediaEmbedInline:'<span class="svgIcon svgIcon--33px svgIcon--addMediaEmbedInline"><svg class=svgIcon-use fill=none height=32 width=32><path d="M12.354 10.354a.5.5 0 00-.708-.708l.708.708zM6 16l-.354-.354a.5.5 0 000 .708L6 16zm5.646 6.354a.5.5 0 00.708-.708l-.708.708zm0-12.708l-6 6 .708.708 6-6-.708-.708zm-6 6.708l6 6 .708-.708-6-6-.708.708z"fill=#1A8917></path><path d="M19.646 21.646a.5.5 0 00.708.708l-.708-.708zM26 16l.354.354a.5.5 0 000-.708L26 16zm-5.646-6.354a.5.5 0 00-.708.708l.708-.708zm0 12.708l6-6-.708-.708-6 6 .708.708zm6-6.708l-6-6-.708.708 6 6 .708-.708z"fill=#1A8917></path><rect height=31 rx=15.5 stroke=#1A8917 width=31 x=.5 y=.5></rect></svg></span>',addCodeBlockInline:'<span class="svgIcon svgIcon--33px svgIcon--addCodeBlockInline"><svg class=svgIcon-use fill=none height=33 viewBox="0 0 32 32"width=33><path clip-rule=evenodd d="M11.05 9.441c.771-.724 1.773-.941 2.7-.941 0 0 .5 0 .5.5s-.5.5-.5.5c-.787 0-1.5.186-2.014.67-.51.479-.914 1.332-.914 2.858 0 1.285-.32 2.232-.907 2.859-.131.14-.272.26-.42.363.148.103.289.223.42.363.587.627.907 1.574.907 2.86 0 1.525.404 2.378.914 2.857.515.484 1.227.67 2.014.67 0 0 .5 0 .5.5s-.5.5-.5.5c-.927 0-1.929-.217-2.7-.941-.776-.73-1.228-1.89-1.228-3.587 0-1.131-.281-1.796-.637-2.175-.352-.376-1.435-.547-1.435-.547s-.5 0-.5-.5.5-.5.5-.5 1.083-.17 1.435-.547c.356-.38.637-1.044.637-2.175 0-1.697.452-2.857 1.229-3.587zm9.9 0c-.771-.724-1.773-.941-2.7-.941 0 0-.5 0-.5.5s.5.5.5.5c.787 0 1.5.186 2.015.67.51.479.913 1.332.913 2.858 0 1.285.32 2.232.907 2.859.131.14.272.26.42.363a2.633 2.633 0 00-.42.363c-.587.627-.907 1.574-.907 2.86 0 1.525-.404 2.378-.913 2.857-.516.484-1.228.67-2.015.67 0 0-.5 0-.5.5s.5.5.5.5c.927 0 1.929-.217 2.7-.941.776-.73 1.229-1.89 1.229-3.587 0-1.131.28-1.796.636-2.175.352-.376 1.435-.547 1.435-.547s.5 0 .5-.5-.5-.5-.5-.5-1.083-.17-1.435-.547c-.356-.38-.637-1.044-.637-2.175 0-1.697-.452-2.857-1.229-3.587z"fill=#1A8917 fill-rule=evenodd></path><rect height=31 rx=15.5 stroke=#1A8917 width=31 x=.5 y=.5></rect></svg></span>',addDividerInline:'<span class="svgIcon svgIcon--33px svgIcon--addDividerInline"><svg class=svgIcon-use fill=none height=32 width=32><path d="M8 10.5a.5.5 0 01.5-.5h15a.5.5 0 010 1h-15a.5.5 0 01-.5-.5z"fill=#1A8917 clip-rule=evenodd fill-rule=evenodd></path><path d="M17 16.5a1 1 0 11-2 0 1 1 0 012 0z"fill=#1A8917></path><path d="M12 16.5a1 1 0 11-2 0 1 1 0 012 0z"fill=#1A8917></path><path d="M22 16.5a1 1 0 11-2 0 1 1 0 012 0z"fill=#1A8917></path><path d="M8 22.5a.5.5 0 01.5-.5h15a.5.5 0 010 1h-15a.5.5 0 01-.5-.5z"fill=#1A8917 clip-rule=evenodd fill-rule=evenodd></path><rect height=31 rx=15.5 stroke=#1A8917 width=31 x=.5 y=.5></rect></svg></span>',checkMark:'<span class="svgIcon svgIcon--codeBlockCheckmark svgIcon--19px"><svg class="svgIcon-use" width="19" height="19" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.76 4.743a.5.5 0 01.167.687l-5.841 9.558-3.95-4.181a.5.5 0 11.728-.687l3.05 3.23 5.16-8.441a.5.5 0 01.687-.166z" fill="currentColor"></path></svg></span>',codeBlockDrop:'<svg class="svgIcon-use" width="19" height="19" viewBox="0 0 24 24" fill="none"><g clip-path="url(#clip0_1082_12841)"><path d="M8.354 9.646a.5.5 0 10-.708.708l.708-.708zM12 14l-.354.354a.5.5 0 00.708 0L12 14zm4.354-3.646a.5.5 0 00-.708-.708l.708.708zm-8.708 0l4 4 .708-.708-4-4-.708.708zm4.708 4l4-4-.708-.708-4 4 .708.708z" fill="currentColor"></path></g></svg>',bold:'<span class="svgIcon svgIcon--21px svgIcon--bold"><svg class=svgIcon-use height=21 width=21><path d="M10.308 17.993h-5.92l.11-.894.783-.12c.56-.11.79-.224.79-.448V5.37c0-.225-.113-.336-.902-.448H4.5l-.114-.894h6.255c4.02 0 5.58 1.23 5.58 3.13 0 1.896-1.78 3.125-3.79 3.463v.11c2.69.34 4.25 1.56 4.25 3.57 0 2.35-2.01 3.69-6.37 3.69l.02.01h-.02zm-.335-12.96H8.967V10.5h1.23c1.788 0 2.79-1.23 2.79-2.683 0-1.685-1.004-2.803-3.006-2.803v.02zm-.223 6.36h-.783v5.588l1.225.23h.22c1.67 0 3.01-1.004 3.01-2.792 0-2.122-1.566-3.016-3.69-3.016h.018z"fill-rule=evenodd></path></svg></span>',italic:'<span class="svgIcon svgIcon--21px svgIcon--italic"><svg class=svgIcon-use height=21 width=21><path d="M9.847 18.04c-.533 0-2.027-.64-1.92-.853l2.027-7.68-.64-.214-1.387 1.494-.427-.427c.534-1.173 1.707-2.667 2.774-2.667.533 0 2.24.534 2.133.854l-2.133 7.786.533.214 1.6-1.067.427.427c-.64 1.066-1.92 2.133-2.987 2.133zm2.347-11.733c-.96 0-1.387-.64-1.387-1.387 0-1.067.747-1.92 1.493-1.92.854 0 1.387.64 1.387 1.493-.107 1.067-.747 1.814-1.493 1.814z"fill-rule=evenodd></path></svg></span>',link:'<span class="svgIcon svgIcon--21px svgIcon--link"><svg class=svgIcon-use height=21 width=21><path d="M2.2 13.17c0-.575.125-1.11.375-1.605l.02-.018v-.02c.014 0 .02-.008.02-.02 0-.014 0-.02.02-.02.122-.256.31-.52.576-.805l3.19-3.18c0-.008 0-.015.01-.02.01-.006.01-.013.01-.02.44-.413.91-.7 1.44-.853-.63.71-1.03 1.5-1.19 2.36-.04.24-.06.52-.06.81 0 .14.01.24.02.33L4.67 12.1c-.19.19-.316.407-.376.653a1.33 1.33 0 00-.057.415c0 .155.02.314.06.477.075.21.2.403.376.58l1.286 1.31c.27.276.62.416 1.03.416.42 0 .78-.14 1.06-.42l1.23-1.25.79-.78 1.15-1.16c.08-.09.19-.22.28-.4.103-.2.15-.42.15-.67 0-.16-.02-.31-.056-.45l-.02-.02v-.02l-.07-.14c0-.01-.013-.03-.04-.06l-.06-.13-.02-.02c0-.02-.01-.03-.02-.05a.592.592 0 00-.143-.16l-.48-.5c0-.042.015-.1.04-.15l.06-.12 1.17-1.14.087-.09.56.57c.023.04.08.1.16.18l.05.04c.006.018.02.036.035.06l.04.054c.01.01.02.025.03.04.03.023.04.046.04.058.04.04.08.09.1.14l.02.02c0 .018.01.03.024.04l.105.197v.02c.098.157.19.384.297.68a1 1 0 01.04.255c.06.21.08.443.08.7 0 .22-.02.43-.06.63-.12.71-.44 1.334-.95 1.865l-.66.67-.97.972-1.554 1.57C8.806 17.654 7.98 18 7.01 18s-1.8-.34-2.487-1.026l-1.296-1.308a3.545 3.545 0 01-.913-1.627 4.541 4.541 0 01-.102-.88v-.01l-.012.01zm5.385-3.433c0-.183.023-.393.07-.63.13-.737.448-1.362.956-1.87l.66-.662.97-.983 1.56-1.56C12.48 3.34 13.3 3 14.27 3c.97 0 1.8.34 2.483 1.022l1.29 1.314c.44.438.744.976.913 1.618.067.32.102.614.102.87 0 .577-.123 1.11-.375 1.605l-.02.01v.02l-.02.04c-.148.27-.35.54-.6.81l-3.187 3.19c0 .01 0 .01-.01.02-.01 0-.01.01-.01.02-.434.42-.916.7-1.427.83.63-.67 1.03-1.46 1.19-2.36.04-.26.06-.53.06-.81 0-.14-.01-.26-.02-.35l1.99-1.97c.18-.21.3-.42.35-.65.04-.12.05-.26.05-.42 0-.16-.02-.31-.06-.48-.07-.19-.19-.38-.36-.58l-1.3-1.3a1.488 1.488 0 00-1.06-.42c-.42 0-.77.14-1.06.41L11.98 6.7l-.79.793-1.157 1.16c-.088.075-.186.21-.294.4-.09.233-.14.46-.14.67 0 .16.02.31.06.452l.02.02v.023l.06.144c0 .006.01.026.05.06l.06.125.02.02c0 .01 0 .013.01.02 0 .005.01.01.01.02.05.08.1.134.14.16l.47.5c0 .04-.02.093-.04.15l-.06.12-1.15 1.15-.1.08-.56-.56a2.31 2.31 0 00-.18-.187c-.02-.01-.02-.03-.02-.04l-.02-.02a.375.375 0 01-.1-.122c-.03-.024-.05-.043-.05-.06l-.1-.15-.02-.02-.02-.04L8 11.4v-.02a5.095 5.095 0 01-.283-.69 1.035 1.035 0 01-.04-.257 2.619 2.619 0 01-.093-.7v.007z"fill-rule=evenodd></path></svg></span>',tBigger:'<span class="svgIcon svgIcon--21px svgIcon--tBigger"><svg class=svgIcon-use height=21 width=21><path d="M3 2v4.747h1.656l.383-2.568.384-.311h3.88V15.82l-.408.38-1.56.12V18h7.174v-1.68l-1.56-.12-.407-.38V3.868h3.879l.36.311.407 2.568h1.656V2z"fill-rule=evenodd></path></svg></span>',tSmaller:'<span class="svgIcon svgIcon--21px svgIcon--tSmaller"><svg class=svgIcon-use height=21 width=21><path d="M4 5.5v4.74h1.657l.384-2.569.384-.312h2.733v8.461l-.41.38-1.91.12V18h7.179v-1.68l-1.912-.12-.405-.38V7.359h2.729l.36.312.408 2.57h1.657V5.5z"fill-rule=evenodd></path></svg></span>',blockquote:'<span class="svgIcon svgIcon--21px svgIcon--blockquote"><svg class=svgIcon-use data-multipart=true height=21 width=21><path d="M15.48 18.024c-2.603 0-4.45-2.172-4.45-4.778 0-3.263 2.498-6.3 6.517-8.803l1.297 1.303c-2.497 1.63-3.91 3.042-3.91 5.214 0 2.824 3.91 3.582 3.91 3.91.11 1.41-1.194 3.15-3.366 3.15h.004v.004z"></path><path d="M6.578 18.024c-2.606 0-4.453-2.172-4.453-4.778 0-3.263 2.497-6.3 6.515-8.803l1.303 1.303c-2.606 1.63-3.907 3.042-3.907 5.106 0 2.823 3.91 3.58 3.91 3.91 0 1.518-1.304 3.257-3.368 3.257z"></path></svg></span>',dropCap:'<span class="svgIcon svgIcon--21px svgIcon--dropCap"><svg class=svgIcon-use height=21 width=21><path d="M1.033 17.57v-.942c0-.15.045-.263.136-.34.09-.08.2-.12.32-.12h18.62c.13 0 .23.04.32.118.09.08.14.192.14.34v.943c0 .1-.05.21-.14.31-.1.1-.21.15-.32.15H1.49c-.105 0-.21-.05-.31-.15-.1-.1-.15-.21-.15-.31zm0-10.135c.694 0 1.195-.058 1.502-.173l.122-.992h1.4v6.425c-.534.048-.88.105-1.038.17-.16.31-.26.682-.29 1.112h4.55c.04-.154.06-.35.05-.6s-.04-.44-.1-.57a5.595 5.595 0 00-1.26-.123V6.266h1.41c.12.654.18 1.01.2 1.067.32.083.81.123 1.45.123V5.04h-8v2.395zm10.395 5.916c0 .15.04.26.13.34.09.09.195.13.31.13h8.24c.115 0 .22-.04.316-.13a.417.417 0 00.143-.32v-.94c0-.11-.048-.22-.15-.32-.1-.1-.202-.15-.31-.15h-8.23c-.11 0-.21.06-.305.16a.507.507 0 00-.144.33v.94-.01zm0-3.47c0 .13.04.23.13.32s.195.13.31.13h8.24c.115 0 .22-.04.316-.13a.396.396 0 00.143-.31v-.95c0-.11-.048-.21-.143-.31a.429.429 0 00-.317-.15h-8.23c-.11 0-.21.05-.305.15a.472.472 0 00-.144.32v.94zm0-3.43a.445.445 0 00.44.46h8.24c.115 0 .22-.04.316-.13a.402.402 0 00.143-.32V5.5a.442.442 0 00-.143-.316.435.435 0 00-.317-.143h-8.23c-.11 0-.21.05-.305.15-.095.1-.143.2-.144.32v.95z"fill-rule=evenodd></path></svg></span>',privateNoteFilled:'<span class="svgIcon svgIcon--25px svgIcon--privatenoteFilled"><svg class=svgIcon-use height=25 width=25><g fill-rule=evenodd><path d="M17.662 4.552H7.346A4.36 4.36 0 003 8.898v5.685c0 2.168 1.614 3.962 3.697 4.28v2.77c0 .303.35.476.59.29l3.904-2.994h6.48c2.39 0 4.35-1.96 4.35-4.35V8.9c0-2.39-1.95-4.346-4.34-4.346zM16 14.31a.99.99 0 01-1.003.99h-4.994C9.45 15.3 9 14.85 9 14.31v-3.02a.99.99 0 011-.99v-.782a2.5 2.5 0 012.5-2.51c1.38 0 2.5 1.13 2.5 2.51v.782c.552.002 1 .452 1 .99v3.02z"></path><path d="M14 9.81c0-.832-.674-1.68-1.5-1.68-.833 0-1.5.84-1.5 1.68v.49h3v-.49z"></path></g></svg></span>',removeThin:'<span class="svgIcon svgIcon--19px svgIcon--removeThin"><svg class=svgIcon-use height=19 width=19><path d="M13.792 4.6l-4.29 4.29-4.29-4.29-.612.613 4.29 4.29-4.29 4.29.613.612 4.29-4.29 4.29 4.29.612-.613-4.29-4.29 4.29-4.29"fill-rule=evenodd></path></svg></span>',mediaInsetCenter:'<span class="svgIcon svgIcon--imageInsetCenter svgIcon--25px"><svg class="svgIcon-use" width="25" height="25"><path d="M5 20.558v-.9c0-.122.04-.226.122-.312a.404.404 0 01.305-.13h13.347a.45.45 0 01.32.13c.092.086.138.19.138.312v.9a.412.412 0 01-.138.313.435.435 0 01-.32.13H5.427a.39.39 0 01-.305-.13.432.432 0 01-.122-.31zm0-3.554V9.01c0-.12.04-.225.122-.31a.4.4 0 01.305-.13h13.347c.122 0 .23.043.32.13.092.085.138.19.138.31v7.994a.462.462 0 01-.138.328.424.424 0 01-.32.145H5.427a.382.382 0 01-.305-.145.501.501 0 01-.122-.328zM5 6.342v-.87c0-.12.04-.23.122-.327A.382.382 0 015.427 5h13.347c.122 0 .23.048.32.145a.462.462 0 01.138.328v.87c0 .12-.046.225-.138.31a.447.447 0 01-.32.13H5.427a.4.4 0 01-.305-.13.44.44 0 01-.122-.31z" fill-rule="evenodd"></path></svg></span>',mediaOutsetCenter:'<span class="svgIcon svgIcon--imageOutsetCenter svgIcon--25px"><svg class="svgIcon-use" width="25" height="25"><path d="M3 17.004V9.01a.4.4 0 01.145-.31.476.476 0 01.328-.13h17.74c.12 0 .23.043.327.13a.4.4 0 01.145.31v7.994a.404.404 0 01-.145.313.48.48 0 01-.328.13H3.472a.483.483 0 01-.327-.13.402.402 0 01-.145-.313zm2.212 3.554v-.87c0-.13.05-.243.145-.334a.472.472 0 01.328-.137H19c.124 0 .23.045.322.137a.457.457 0 01.138.335v.86c0 .12-.046.22-.138.31a.478.478 0 01-.32.13H5.684a.514.514 0 01-.328-.13.415.415 0 01-.145-.32zm0-14.246v-.84c0-.132.05-.243.145-.334A.477.477 0 015.685 5H19a.44.44 0 01.322.138.455.455 0 01.138.335v.84a.451.451 0 01-.138.334.446.446 0 01-.32.138H5.684a.466.466 0 01-.328-.138.447.447 0 01-.145-.335z" fill-rule="evenodd"></path></svg></span>',mediaFillWidth:'<span class="svgIcon svgIcon--imageFillWidth svgIcon--25px"><svg class="svgIcon-use" width="25" height="25"><path d="M4.027 17.24V5.492c0-.117.046-.216.14-.3a.453.453 0 01.313-.123h17.007c.117 0 .22.04.313.12.093.08.14.18.14.3v11.74c0 .11-.046.21-.14.3a.469.469 0 01-.313.12H4.48a.432.432 0 01-.314-.13.41.41 0 01-.14-.3zm2.943 3.407v-.833a.45.45 0 01.122-.322.387.387 0 01.276-.132H18.61a.35.35 0 01.27.132.472.472 0 01.116.322v.833c0 .117-.04.216-.116.3a.361.361 0 01-.27.123H7.368a.374.374 0 01-.276-.124.405.405 0 01-.122-.3z" fill-rule="evenodd"></path></svg></span>'},ye={titlePlaceholder:"Title",mainPlaceholder:"Tell your story...",titleLabel:"Title",subtitleLabel:"Subtitle",kickerLabel:"Kicker",bold:"Bold",italic:"Italic",link:"Link",linkPlaceholder:"Paste or type a link…",bigTitle:"Big title",smallTitle:"Small title",quote:"Blockquote",mediaInset:"Display media within text column",mediaOutset:"Expand media beyond text column",mediaFill:"Stretch media to fill screen",altTextButton:"Alt text",altDescription:"Describe the image for accessibility",addContent:"Add an image, video, embed, or new part",addImage:"Add an image",unsplashImage:"Add an image from Unsplash",unsplashSearch:"Type keywords to search Unsplash, and press Enter",addVideo:"Add a video",videoUrl:"Paste a YouTube, Vimeo, or other video link, and press Enter",addEmbed:"Add an embed",embedUrl:"Paste a link to embed content from another site (e.g. X) and press Enter",codeBlock:"Add a new code block",addPart:"Add a new part",imgCaption:"Type caption for image (optional)",embedCaption:"Type caption for embed (optional)"};for(var be={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},we={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ee="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ke="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Ce=0;Ce<10;Ce++)be[48+Ce]=be[96+Ce]=String(Ce);for(Ce=1;Ce<=24;Ce++)be[Ce+111]="F"+Ce;for(Ce=65;Ce<=90;Ce++)be[Ce]=String.fromCharCode(Ce+32),we[Ce]=String.fromCharCode(Ce);for(var Ae in be)we.hasOwnProperty(Ae)||(we[Ae]=be[Ae]);const Me="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function xe(e){let t,r,n,s,i=e.split(/-(?!$)/),o=i[i.length-1];"Space"==o&&(o=" ");for(let e=0;e<i.length-1;e++){let o=i[e];if(/^(cmd|meta|m)$/i.test(o))s=!0;else if(/^a(lt)?$/i.test(o))t=!0;else if(/^(c|ctrl|control)$/i.test(o))r=!0;else if(/^s(hift)?$/i.test(o))n=!0;else{if(!/^mod$/i.test(o))throw new Error("Unrecognized modifier name: "+o);Me?s=!0:r=!0}}return t&&(o="Alt-"+o),r&&(o="Ctrl-"+o),s&&(o="Meta-"+o),n&&(o="Shift-"+o),o}function Ne(e,t,r=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),r&&t.shiftKey&&(e="Shift-"+e),e}function Se(e){let t=function(e){let t=Object.create(null);for(let r in e)t[xe(r)]=e[r];return t}(e);return function(e,r){let n,s=function(e){var t=!(Ee&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ke&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?we:be)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(r),i=t[Ne(s,r)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(r.shiftKey){let n=t[Ne(s,r,!1)];if(n&&n(e.state,e.dispatch,e))return!0}if((r.shiftKey||r.altKey||r.metaKey||s.charCodeAt(0)>127)&&(n=be[r.keyCode])&&n!=s){let s=t[Ne(n,r)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}function Ie(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}function Te(e,t){return"style"in e?e:{...e,getAttrs:r=>{const n=e.getAttrs?e.getAttrs(r):e.attrs;if(!1===n)return!1;const s={};for(const e of t){const t=e.attribute.parseDOM?e.attribute.parseDOM(r):Ie(r.getAttribute(e.name));null!=t&&(s[e.name]=t)}return{...n,...s}}}}function _e(e,t,r){return t.filter((t=>t.type===e.type.name)).filter((e=>e.attribute.rendered??!0)).filter((({attribute:{renderedOnMode:e}})=>!e||"published"===e==!!r.published)).map((t=>t.attribute.toDOM?t.attribute.toDOM(e.attrs)||{}:{[t.name]:e.attrs[t.name]})).reduce(((e,t)=>function(...e){return e.filter((e=>!!e)).reduce(((e,t)=>{for(const[r,n]of Object.entries(t))if(r in e)if("class"===r){const t=n?String(n).split(" "):[],s=e[r]?String(e[r]).split(" "):[];for(const e of t)s.includes(e)||s.push(e);e[r]=s.join(" ")}else if("style"===r){const t=n?String(n).split(";").map((e=>e.trim())).filter(Boolean):[],s=e[r]?String(e[r]).split(";").map((e=>e.trim())).filter(Boolean):[],i=new Map;for(const e of s){const[t,r]=e.split(":").map((e=>e.trim()));t&&r&&i.set(t,r)}for(const e of t){const[t,r]=e.split(":").map((e=>e.trim()));t&&r&&i.set(t,r)}e[r]=Array.from(i.entries()).map((([e,t])=>`${e}: ${t}`)).join("; ")}else e[r]=n;else e[r]=n;return e}),{})}(e,t)),{})}var Oe=200,De=function(){};De.prototype.append=function(e){return e.length?(e=De.from(e),!this.length&&e||e.length<Oe&&this.leafAppend(e)||this.length<Oe&&e.leafPrepend(this)||this.appendInner(e)):this},De.prototype.prepend=function(e){return e.length?De.from(e).append(this):this},De.prototype.appendInner=function(e){return new Le(this,e)},De.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?De.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},De.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},De.prototype.forEach=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},De.prototype.map=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=this.length);var n=[];return this.forEach((function(t,r){return n.push(e(t,r))}),t,r),n},De.from=function(e){return e instanceof De?e:e&&e.length?new qe(e):De.empty};var qe=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,r){return 0==e&&r==this.length?this:new t(this.values.slice(e,r))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,r,n){for(var s=t;s<r;s++)if(!1===e(this.values[s],n+s))return!1},t.prototype.forEachInvertedInner=function(e,t,r,n){for(var s=t-1;s>=r;s--)if(!1===e(this.values[s],n+s))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Oe)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Oe)return new t(e.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(t.prototype,r),t}(De);De.empty=new qe([]);var Le=function(e){function t(t,r){e.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,r,n){var s=this.left.length;return!(t<s&&!1===this.left.forEachInner(e,t,Math.min(r,s),n))&&(!(r>s&&!1===this.right.forEachInner(e,Math.max(t-s,0),Math.min(this.length,r)-s,n+s))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,r,n){var s=this.left.length;return!(t>s&&!1===this.right.forEachInvertedInner(e,t-s,Math.max(r,s)-s,n+s))&&(!(r<s&&!1===this.left.forEachInvertedInner(e,Math.min(t,s),r,n))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var r=this.left.length;return t<=r?this.left.slice(e,t):e>=r?this.right.slice(e-r,t-r):this.left.slice(e,r).append(this.right.slice(0,t-r))},t.prototype.leafAppend=function(e){var r=this.right.leafAppend(e);if(r)return new t(this.left,r)},t.prototype.leafPrepend=function(e){var r=this.left.leafPrepend(e);if(r)return new t(r,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(De);class Re{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let r,n,s=this.items.length;for(;;s--){if(this.items.get(s-1).selection){--s;break}}t&&(r=this.remapping(s,this.items.length),n=r.maps.length);let i,o,a=e.tr,l=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return r||(r=this.remapping(s,t+1),n=r.maps.length),n--,void c.push(e);if(r){c.push(new Pe(e.map));let t,s=e.step.map(r.slice(n));s&&a.maybeStep(s).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new Pe(t,void 0,void 0,l.length+c.length))),n--,t&&r.appendMap(t,n)}else a.maybeStep(e.step);return e.selection?(i=r?e.selection.map(r.slice(n)):e.selection,o=new Re(this.items.slice(0,s).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:o,transform:a,selection:i}}addTransform(e,t,r,n){let s=[],i=this.eventCount,o=this.items,a=!n&&o.length?o.get(o.length-1):null;for(let r=0;r<e.steps.length;r++){let l,c=e.steps[r].invert(e.docs[r]),d=new Pe(e.mapping.maps[r],c,t);(l=a&&a.merge(d))&&(d=l,r?s.pop():o=o.slice(0,o.length-1)),s.push(d),t&&(i++,t=void 0),n||(a=d)}let l=i-r.depth;return l>ze&&(o=function(e,t){let r;return e.forEach(((e,n)=>{if(e.selection&&0==t--)return r=n,!1})),e.slice(r)}(o,l),i-=l),new Re(o.append(s),i)}remapping(e,t){let r=new c;return this.items.forEach(((t,n)=>{let s=null!=t.mirrorOffset&&n-t.mirrorOffset>=e?r.maps.length-t.mirrorOffset:void 0;r.appendMap(t.map,s)}),e,t),r}addMaps(e){return 0==this.eventCount?this:new Re(this.items.append(e.map((e=>new Pe(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],n=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,o=this.eventCount;this.items.forEach((e=>{e.selection&&o--}),n);let a=t;this.items.forEach((t=>{let n=s.getMirror(--a);if(null==n)return;i=Math.min(i,n);let l=s.maps[n];if(t.step){let i=e.steps[n].invert(e.docs[n]),c=t.selection&&t.selection.map(s.slice(a+1,n));c&&o++,r.push(new Pe(l,i,c))}else r.push(new Pe(l))}),n);let l=[];for(let e=t;e<i;e++)l.push(new Pe(s.maps[e]));let c=this.items.slice(0,n).append(l).append(r),d=new Re(c,o);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,n=[],s=0;return this.items.forEach(((i,o)=>{if(o>=e)n.push(i),i.selection&&s++;else if(i.step){let e=i.step.map(t.slice(r)),o=e&&e.getMap();if(r--,o&&t.appendMap(o,r),e){let a=i.selection&&i.selection.map(t.slice(r));a&&s++;let l,c=new Pe(o.invert(),e,a),d=n.length-1;(l=n.length&&n[d].merge(c))?n[d]=l:n.push(c)}}else i.map&&r--}),this.items.length,0),new Re(De.from(n.reverse()),s)}}Re.empty=new Re(De.empty,0);class Pe{constructor(e,t,r,n){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=n}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Pe(t.getMap().invert(),t,this.selection)}}}class He{constructor(e,t,r,n,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=n,this.prevComposition=s}}const ze=20;function Be(e){let t=[];for(let r=e.length-1;r>=0&&0==t.length;r--)e[r].forEach(((e,r,n,s)=>t.push(n,s)));return t}function $e(e,t){if(!e)return null;let r=[];for(let n=0;n<e.length;n+=2){let s=t.map(e[n],1),i=t.map(e[n+1],-1);s<=i&&r.push(s,i)}return r}let Ve=!1,Ue=null;function je(e){let t=e.plugins;if(Ue!=t){Ve=!1,Ue=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Ve=!0;break}}return Ve}const Fe=new l("history"),We=new l("closeHistory");function Ge(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new a({key:Fe,state:{init:()=>new He(Re.empty,Re.empty,null,0,-1),apply:(t,r,n)=>function(e,t,r,n){let s,i=r.getMeta(Fe);if(i)return i.historyState;r.getMeta(We)&&(e=new He(e.done,e.undone,null,0,-1));let o=r.getMeta("appendedTransaction");if(0==r.steps.length)return e;if(o&&o.getMeta(Fe))return o.getMeta(Fe).redo?new He(e.done.addTransform(r,void 0,n,je(t)),e.undone,Be(r.mapping.maps),e.prevTime,e.prevComposition):new He(e.done,e.undone.addTransform(r,void 0,n,je(t)),null,e.prevTime,e.prevComposition);if(!1===r.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(s=r.getMeta("rebased"))?new He(e.done.rebased(r,s),e.undone.rebased(r,s),$e(e.prevRanges,r.mapping),e.prevTime,e.prevComposition):new He(e.done.addMaps(r.mapping.maps),e.undone.addMaps(r.mapping.maps),$e(e.prevRanges,r.mapping),e.prevTime,e.prevComposition);{let s=r.getMeta("composition"),i=0==e.prevTime||!o&&e.prevComposition!=s&&(e.prevTime<(r.time||0)-n.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let r=!1;return e.mapping.maps[0].forEach(((e,n)=>{for(let s=0;s<t.length;s+=2)e<=t[s+1]&&n>=t[s]&&(r=!0)})),r}(r,e.prevRanges)),a=o?$e(e.prevRanges,r.mapping):Be(r.mapping.maps);return new He(e.done.addTransform(r,i?t.selection.getBookmark():void 0,n,je(t)),Re.empty,a,r.time,null==s?e.prevComposition:s)}}(r,n,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,n="historyUndo"==r?Je:"historyRedo"==r?Ze:null;return!!n&&(t.preventDefault(),n(e.state,e.dispatch))}}}})}function Ke(e,t){return(r,n)=>{let s=Fe.getState(r);if(!s||0==(e?s.undone:s.done).eventCount)return!1;if(n){let i=function(e,t,r){let n=je(t),s=Fe.get(t).spec.config,i=(r?e.undone:e.done).popEvent(t,n);if(!i)return null;let o=i.selection.resolve(i.transform.doc),a=(r?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),s,n),l=new He(r?a:i.remaining,r?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(Fe,{redo:r,historyState:l})}(s,r,e);i&&n(t?i.scrollIntoView():i)}return!0}}const Je=Ke(!1,!0),Ze=Ke(!0,!0);function Qe(e){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));return!!o&&(!r||(s.node(o.depth-1).type==e?function(e,t,r,s){let i=e.tr,o=s.end,a=s.$to.end(s.depth);o<a&&(i.step(new u(o-1,a,o,a,new d(n.from(r.create(null,s.parent.copy())),1,0),1,!0)),s=new p(i.doc.resolve(s.$from.pos),i.doc.resolve(a),s.depth));const l=f(s);if(null==l)return!1;i.lift(s,l);let c=i.doc.resolve(i.mapping.map(o,-1)-1);m(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos);return t(i.scrollIntoView()),!0}(t,r,e,o):function(e,t,r){let s=e.tr,i=r.parent;for(let e=r.end,t=r.endIndex-1,n=r.startIndex;t>n;t--)e-=i.child(t).nodeSize,s.delete(e-1,e+1);let o=s.doc.resolve(r.start),a=o.nodeAfter;if(s.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let l=0==r.startIndex,c=r.endIndex==i.childCount,h=o.node(-1),p=o.index(-1);if(!h.canReplace(p+(l?0:1),p+1,a.content.append(c?n.empty:n.from(i))))return!1;let f=o.pos,m=f+a.nodeSize;return s.step(new u(f-(l?1:0),m+(c?1:0),f+1,m-1,new d((l?n.empty:n.from(i.copy(n.empty))).append(c?n.empty:n.from(i.copy(n.empty))),l?0:1,c?0:1),l?0:1)),t(s.scrollIntoView()),!0}(t,r,o)))}}function Ye(e,t){const{tr:r}=e,{selection:n}=r,{ranges:s}=n;if(!t)return!0;for(const{$from:t,$to:n}of s)e.doc.nodesBetween(t.pos,n.pos,((e,t)=>{if(e.type.isText)return;const{doc:n,mapping:s}=r,i=n.resolve(s.map(t)),o=n.resolve(s.map(t+e.nodeSize)),a=i.blockRange(o);if(!a)return;const l=f(a);if(e.type.isTextblock){const{defaultType:e}=i.parent.contentMatchAt(i.index());r.setNodeMarkup(a.start,e)}null!==l&&r.lift(a,l)}));return t(r),!0}function Xe(t,r){const{selection:n,doc:s}=t,{empty:i,$anchor:o}=n,{pos:a,parent:l}=o,c=o.parent.isTextblock&&a>0?s.resolve(a-1):o,d=c.parent.type.spec.isolating,h=o.pos-o.parentOffset,u=d&&1===c.parent.childCount?h===o.pos:e.atStart(s).from===a;return u&&s.childCount>1&&""===l.textContent?(s.firstChild,!(o.depth>1)&&(r&&r(t.tr.delete(0,l.nodeSize)),!0)):!i||"codeBlock"!==o.parent.type.name||!u&&l.textContent.length?!(!i||!l.type.isTextblock||l.textContent.length||!u||u&&"paragraph"===o.parent.type.name)&&Ye(t,r):Ye(t,r)}function et(e,t){const{selection:r}=e,{$anchor:n,empty:s}=r;return!(!s||n.parent.textContent)&&(t&&t(e.tr.setMeta("removePlaceholder",{pos:r.from-1})),!0)}function tt(e,t){const r=e.plugins;for(let n=0;n<r.length;n+=1){const s=r[n];let i;if(s.spec.isInputRules&&(i=s.getState(e))){if(t){const r=e.tr,n=i.transform;for(let e=n.steps.length-1;e>=0;e-=1)r.step(n.steps[e].invert(n.docs[e]));if(i.text){const t=r.doc.resolve(i.from).marks();r.replaceWith(i.from,i.to,e.schema.text(i.text,t))}else r.delete(i.from,i.to);t(r)}return!0}}return!1}const rt=(...e)=>(t,r,n)=>{for(const s of e)if(s?.(t,r,n))return!0;return!1},nt=(e,t)=>{const{tr:r}=e;return t&&t(r.setSelection(new k(r.doc))),!0};function st({schema:t,commands:r}){const s="undefined"!=typeof navigator&&/Mac/.test(navigator.platform)||["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,i={},o=rt(tt,Xe,M,A,C,et);i.Backspace=i["Mod-Backspace"]=i["Shift-Backspace"]=o;const a=rt(M,N,x);var l,c;i["Mod-Delete"]=a,i.Enter=rt(g,t.nodes.listItem?(l=t.nodes.listItem,function(t,r){let{$from:s,$to:i,node:o}=t.selection;if(o&&o.isBlock||s.depth<2||!s.sameParent(i))return!1;let a=s.node(-1);if(a.type!=l)return!1;if(0==s.parent.content.size&&s.node(-1).childCount==s.indexAfter(-1)){if(3==s.depth||s.node(-3).type!=l||s.index(-2)!=s.node(-2).childCount-1)return!1;if(r){let i=n.empty,o=s.index(-1)?1:s.index(-2)?2:3;for(let e=s.depth-o;e>=s.depth-3;e--)i=n.from(s.node(e).copy(i));let a=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3;i=i.append(n.from(l.createAndFill()));let c=s.before(s.depth-(o-1)),h=t.tr.replace(c,s.after(-a),new d(i,4-o,0)),u=-1;h.doc.nodesBetween(c,h.doc.content.size,((e,t)=>{if(u>-1)return!1;e.isTextblock&&0==e.content.size&&(u=t+1)})),u>-1&&h.setSelection(e.near(h.doc.resolve(u))),r(h.scrollIntoView())}return!0}let u=i.pos==s.end()?a.contentMatchAt(0).defaultType:null,p=t.tr.delete(s.pos,i.pos),f=u?[c?{type:l,attrs:c}:null,{type:u}]:void 0;return!!h(p.doc,s.pos,2,f)&&(r&&r(p.split(s.pos,2,f).scrollIntoView()),!0)}):null,b,y,v),i["Mod-Enter"]=rt(g,r.setHorizontalRule);const{listItem:p}=t.nodes;if(p){const e=Qe(p),t=function(e){return function(t,r){let{$from:s,$to:i}=t.selection,o=s.blockRange(i,(t=>t.childCount>0&&t.firstChild.type==e));if(!o)return!1;let a=o.startIndex;if(0==a)return!1;let l=o.parent,c=l.child(a-1);if(c.type!=e)return!1;if(r){let s=c.lastChild&&c.lastChild.type==l.type,i=n.from(s?e.create():null),a=new d(n.from(e.create(null,n.from(l.type.create(null,i)))),s?3:1,0),h=o.start,p=o.end;r(t.tr.step(new u(h-(s?3:1),p,h,p,a,1,!0)).scrollIntoView())}return!0}}(p);i["Mod-["]=e,i["Shift-Tab"]=e,i["Mod-]"]=t,i.Tab=rt(r.tabInCode,t)}else i.Tab=r.tabInCode;return i["Mod-a"]=nt,s&&(i["Ctrl-h"]=i["Alt-Backspace"]=o,i["Ctrl-d"]=i["Ctrl-Alt-Backspace"]=i["Alt-Delete"]=i["Alt-d"]=a,i["Ctrl-a"]=w,i["Ctrl-e"]=E),i["Mod-z"]=Je,i["Mod-Shift-z"]=i["Mod-y"]=Ze,i}class it{find;handler;constructor(e){this.find=e.find,this.handler=e.handler}}const ot=(e,t,r)=>{if(I(t))return[...e.matchAll(t)];return(t(e,r)??[]).map((({text:e,index:t,replaceWith:r,data:n})=>{const s=[e];return s.index=t,s.input=e,s.data=n,r&&!e.includes(r)&&console.warn('[Medium-ProEditor warn]: "replaceWith" must be part of "text".'),r&&s.push(r),s}))};function at({rules:e,commands:t}){let r=!1,n="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;return new a({props:{handleDOMEvents:{paste:(e,t)=>{const s=t.clipboardData?.getData("text/html");return n=t,r=!!s?.includes("data-pm-slice"),!1}}},appendTransaction:(s,i,o)=>{if(!("paste"===s[0].getMeta("uiEvent")&&!r))return;const a=i.doc.content.findDiffStart(o.doc.content),l=i.doc.content.findDiffEnd(o.doc.content);return"number"==typeof a&&l&&a!==l.b?function({commands:e,state:t,from:r,to:n,rules:s,pasteEvent:i}){const o=t.tr,a=S({state:t,transaction:o});let l=!1;return t.doc.nodesBetween(r,n,((t,c)=>{if(!t.isTextblock||t.type.spec.code)return;const d=Math.max(r,c),h=Math.min(n,c+t.content.size),u=t.textBetween(d-c,h-c,void 0,"");for(const t of s)for(const r of ot(u,t.find,i)){if(void 0===r.index)continue;const n=d+r.index+1,s=n+r[0].length,c={from:o.mapping.map(n),to:o.mapping.map(s)};null!==t.handler({commands:e,state:a,range:c,match:r,pasteEvent:i})&&(l=!0)}})),l&&o.steps.length?o:null}({rules:e,state:o,commands:t,from:Math.max(a-1,0),to:l.b-1,pasteEvent:n}):void 0}})}const lt=new l("focus");const ct="֑-߿יִ-﷽ﹰ-ﻼ",dt="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",ht=new RegExp(`^[^${dt}]*[${ct}]`),ut=new RegExp(`^[^${ct}]*[${dt}]`);const pt=["h3","h4","paragraph"];const ft=new l("headlineSet");function mt(e){return R("span",{className:"heading-label",attributes:{"data-heading-label":e}})}function gt(e,t){return t.from>=e.from&&t.to<=e.to}function vt(e,t){const{doc:r}=e,n=[],s=[],i={};let o=null,a=!1,l=!1;const c=lt.getState(e),d={from:c?.from??0,to:c?.to??0};return r.forEach(((e,r,c)=>{if(a)return;const h=e.type.name;if("paragraph"!==h||""!==e.textContent.trim()||o)if("h3"!==h||o&&"h3"===o.node.type.name)if("h4"!==h||o&&"h4"===o.node.type.name)a=!0;else{if("h3"===o?.node.type.name)return n.push(_.node(r,r+e.nodeSize,{class:"subtitle"})),s.push(_.widget(r+1,(()=>mt(t.options.messages.subtitleLabel)))),i.subtitle=c,l||=gt(d,{from:r,to:r+e.nodeSize}),void(a=!0);o={node:e,pos:r,index:c}}else{if(n.push(_.node(r,r+e.nodeSize,{class:"title"})),s.push(_.widget(r+1,(()=>mt(t.options.messages.titleLabel)))),i.title=c,l||=gt(d,{from:r,to:r+e.nodeSize}),"h4"===o?.node.type.name){const e={from:o.pos,to:o.pos+o.node.nodeSize};n.push(_.node(e.from,e.to,{class:"kicker"})),s.push(_.widget(e.from+1,(()=>mt(t.options.messages.kickerLabel)))),i.kicker=o.index,l||=gt(d,e)}o={node:e,pos:r,index:c}}})),l&&n.push(...s),{decorations:T.create(r,n),indexes:i}}function yt(e){return new a({key:ft,state:{init:(t,r)=>vt(r,e),apply:(t,r,n,s)=>vt(s,e)},props:{decorations:e=>ft.getState(e)?.decorations??T.empty}})}const bt=new l("placeholders");function wt(e){const{messages:{titleLabel:t,mainPlaceholder:r,imgCaption:n,embedCaption:s}}=e.options,i=["paragraph","h3","h4"],o=["figcaption"],l=[...i,...o];let c=!0;function d({defaultMessage:e,childCount:o,index:a,node:l,parent:c}){if(e)return e;if("figcaption"===l.type.name&&c&&c.content.size>0)return"image"===c.firstChild?.type.name?n:s;if(i.includes(l.type.name)){if(1===o)return r;if(o<=2)return 0===a?t:r}return null}let h=!1;return new a({key:bt,state:{init:()=>({decorations:T.empty,placeholders:new Map}),apply(e,n,s,a){const u=e.getMeta("removePlaceholder");u&&void 0!==u.pos&&n.placeholders.set(u.pos,!1);const p=e.getMeta("addPlaceholder");if(void 0!==p?.pos&&(n.placeholders.set(p.pos,{message:p.message,class:p.class}),p.removeOnAnyTr&&(c=!0)),!e.docChanged&&!n.placeholders.size&&!c)return n;const f=[],m=a.doc.childCount,g=s.doc.childCount;return a.doc.descendants(((e,a,c,u)=>{if(!l.includes(e.type.name))return!1;const p=n.placeholders.get(a);if(!1===p)return 1===u&&(h=!0),!1;if(p){const t=d({defaultMessage:p.message,childCount:m,index:u,node:e,parent:c});if(t)return f.push(_.node(a,a+e.nodeSize,{"data-placeholder":t,class:p.class})),!1}if(!function({node:e,index:t}){return(o.includes(e.type.name)||t<=2&&i.includes(e.type.name))&&!e.textContent}({node:e,index:u}))return!1;let v=d({childCount:m,index:u,node:e,parent:c});if(1===m)v=r,h=!1;else if(2===m){if(0===u)v=t;else if(1===u&&g<=2){const t=u<s.doc.childCount&&s.doc.child(u)?.textContent!==e.textContent;v=!h||1===g||t?r:null}else v=null,h=!0;v===r&&(h=!1)}v&&f.push(_.node(a,a+e.nodeSize,{"data-placeholder":v}))})),c&&!n.placeholders.size&&(c=!1),n.placeholders.clear(),{decorations:T.create(a.doc,f),placeholders:n.placeholders}}},props:{decorations(e){return this.getState(e).decorations}}})}const Et=["paragraph","h3","h4","blockquote","pullquote"],kt=new l("trailingNode");const Ct=P.create({name:"core",priority:999,addGlobalAttributes:({options:e})=>[{types:L,attributes:{name:{default:null,renderedOnMode:"edit",parseDOM:e=>e.getAttribute("name"),toDOM:e=>e.name?{name:e.name}:{}}}},{types:["paragraph","h3","h4"],mode:"published",attributes:{class:{default:null}}},{types:["mention"],attributes:{"data-user-id":{default:null,parseDOM:e=>e.getAttribute("data-user-id"),toDOM:e=>({"data-user-id":e["data-user-id"]})},"data-tooltip-position":{default:null,renderedOnMode:"edit",parseDOM:e=>e.getAttribute("data-tooltip-position"),toDOM:e=>({"data-tooltip-position":e["data-tooltip-position"]})},"data-tooltip-type":{default:null,renderedOnMode:"edit",parseDOM:e=>e.getAttribute("data-tooltip-type"),toDOM:e=>({"data-tooltip-type":e["data-tooltip-type"]})}}},{types:["link"],attributes:{"data-tooltip":{default:null,renderedOnMode:"edit",parseDOM:e=>e.getAttribute("data-tooltip"),toDOM:e=>({"data-tooltip":e["data-tooltip"]})},"data-tooltip-position":{default:null,renderedOnMode:"edit",parseDOM:e=>e.getAttribute("data-tooltip-position"),toDOM:e=>({"data-tooltip-position":e["data-tooltip-position"]})}}},{types:pt,attributes:{dir:{default:null,rendered:!0,parseDOM:e=>e.getAttribute("dir"),toDOM:e=>({dir:e.dir})}}}],extendNodeSchema:()=>({doc:{content:"block+"},text:{group:"inline"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:({HTMLAttributes:e})=>["p",e,0]}}),addPlugins(){const e=[Ge(),(t=this.editor,new a({key:new l("editable"),props:{editable:()=>t.isEditable}})),(this.editor,new a({key:lt,state:{init:()=>({decorations:T.empty,from:null,to:null}),apply(e,t){const{selection:r}=e,n=r.$head,s=n.node();if(!s)return{decorations:T.empty,from:null,to:null};const i=n.depth>0?n.before(n.depth):0,o=i+s.nodeSize;return r.from>=i&&r.to<=o?{decorations:T.create(e.doc,[_.node(i,o,{class:"is-selected"})]),from:i,to:o}:{decorations:T.empty,from:null,to:null}}},props:{decorations:e=>lt.getState(e).decorations}})),yt(this.editor),new a({key:kt,appendTransaction:(e,t,r)=>{if(!kt.getState(r))return;const{doc:n,tr:s,schema:i}=r,{anchor:o}=r.selection,a=n.content.size;return 1===n.childCount&&(0===o||o<=n.child(0).nodeSize)&&s.setMeta("removePlaceholder",{pos:a}),s.insert(a,i.nodes.paragraph.create())},state:{init:(e,t)=>{const r=t.tr.doc.lastChild;return!(r&&Et.includes(r.type.name))},apply:(e,t)=>{if(!e.docChanged)return t;const r=e.doc.lastChild;return!(r&&Et.includes(r.type.name))}}}),wt(this.editor),H()];var t;return this.editor.options.autoTextDirection&&e.push(new a({key:new l("textDirection"),appendTransaction:(e,{doc:t},{doc:r,tr:n})=>{if(!e.some((e=>!!e.docChanged))||t.eq(r))return;const s=O(t,e);for(const{newRange:e}of D(s)){const t=q(r,e,(e=>pt.includes(e.type.name)));for(const{node:e,pos:r}of t){const t=0===(i=e.textContent).length?null:ht.test(i)?"rtl":ut.test(i)?"ltr":null;t!==e.attrs.dir&&n.setNodeAttribute(r,"dir",t)}}var i;return s.steps.length?n:null}})),e}});function At(...e){return t=>{for(const r of e)if(r(t))return!0;return!1}}function Mt(e,t,r){const n=[];if(e===t){const t=r.resolve(e);for(const e of t.marks()){const r=$(t,e.type);r&&n.push({mark:e,...r})}}else r.nodesBetween(e,t,((e,t)=>{if(e&&void 0!==e.nodeSize)for(const r of e.marks)n.push({from:t,to:t+e.nodeSize,mark:r})}));return n}function xt(e){return new V({find:e.find,handler:({state:t,range:r,match:n})=>{const s=U(e.getAttributes,void 0,n);if(!1===s||null===s)return null;const{tr:i}=t,o=n[n.length-1],a=n[0];if(o){const n=a.search(/\S/),l=r.from+a.indexOf(o),c=l+o.length;if(Mt(r.from,r.to,t.doc).filter((t=>t.mark.type.excluded.find((r=>r===e.type&&r!==t.mark.type)))).filter((e=>e.to>l)).length)return null;c<r.to&&i.delete(c,r.to),l>r.from&&i.delete(r.from+n,l);const d=r.from+n+o.length;i.addMark(r.from+n,d,e.type.create(s||{})),i.removeStoredMark(e.type)}}})}function Nt(e){return new V({find:e.find,handler:({state:t,range:r,match:n})=>{const s=U(e.getAttributes,void 0,n)||{};console.log("Range",r),console.log("Attributes",s),console.log("Type",e.type);const i=t.tr.delete(r.from,r.to),o=i.doc.resolve(r.from).blockRange();console.log("Block range",o);const a=o&&j(o,e.type,s);if(console.log("Wrapping",a),!a)return null;i.wrap(o,a);const l=i.doc.resolve(r.from-1).nodeBefore;l&&l.type===e.type&&m(i.doc,r.from-1)&&(!e.joinPredicate||e.joinPredicate(n,l))&&i.join(r.from-1)}})}const St=/^\s*>\s$/,It=/^\s*>>\s$/,Tt=P.create({name:"blockquote",extendNodeSchema:()=>({blockquote:{content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"blockquote",priority:100}],toDOM:({HTMLAttributes:e})=>["blockquote",{HTMLAttributes:e},0]},pullquote:{content:"inline*",group:"block",marks:"link",defining:!0,parseDOM:[{priority:150,tag:"blockquote.pullquote"}],toDOM:({HTMLAttributes:e})=>["blockquote",{class:"pullquote",...e},0]}}),addHighlightMenuItems(){return[{name:this.name,type:"text",priority:500,isActive:At((e=>z(e,this.schema.nodes.blockquote)),(e=>z(e,this.schema.nodes.pullquote))),execute:this.commands.triggerCycleQuote,icon:this.editor.options.icons.blockquote,title:this.editor.options.messages.quote}]},addInputRules(){return this.editor.options.markdownShortcuts?[F({find:St,type:this.schema.nodes.blockquote}),F({find:It,type:this.schema.nodes.pullquote})]:[]},addCommands:()=>({triggerCycleQuote:(e,t)=>{const{blockquote:r,pullquote:n,paragraph:s}=e.schema.nodes;return t&&function(e,t,r){for(let n=0;n<r.length;n++)if(z(e,r[n])){const s=r[(n+1)%r.length];return void B(s)(e,t)}B(r[0])(e,t)}(e,t,[r,n,s]),!0}}),addKeyboardShortcuts(){return{"Mod-Alt-5":this.commands.triggerCycleQuote}}});function _t(e,r){const{selection:n}=e;let s=null;if(n instanceof t&&(s=n.$cursor),s){const t=e.storedMarks??s.marks();return!!r.isInSet(t)||!t.some((e=>e.type.excludes(r)))}const{ranges:i}=n;return i.some((({$from:t,$to:n})=>{let s=0===t.depth&&(e.doc.inlineContent&&e.doc.type.allowsMarkType(r));return e.doc.nodesBetween(t.pos,n.pos,((e,t,n)=>{if(s)return!1;if(e.isInline){const t=!n||n.type.allowsMarkType(r),i=!!r.isInSet(e.marks)||!e.marks.some((e=>e.type.excludes(r)));s=t&&i}return!s})),s}))}const Ot=(e,t={},r={})=>(n,s)=>{const{extendEmptyMarkRange:i=!1}=r;return W(n,e,t)?G(e,{extendEmptyMarkRange:i})(n,s):K(e,t)(n,s)};function Dt(e){return new it({find:e.find,handler:({state:t,range:r,match:n,pasteEvent:s})=>{const i=U(e.getAttributes,void 0,n,s);if(!1===i||null===i)return null;const{tr:o}=t,a=n[n.length-1],l=n[0];let c=r.to;if(a){const n=l.search(/\S/),s=r.from+l.indexOf(a),d=s+a.length;if(Mt(r.from,r.to,t.doc).filter((t=>t.mark.type.excluded.find((r=>r===e.type&&r!==t.mark.type)))).filter((e=>e.to>s)).length)return null;d<r.to&&o.delete(d,r.to),s>r.from&&o.delete(r.from+n,s),c=r.from+n+a.length,o.addMark(r.from+n,c,e.type.create(i||{})),o.removeStoredMark(e.type)}}})}const qt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Lt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Rt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Pt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ht=P.create({name:"bold",extendMarkSchema:()=>({bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>["strong",0]}}),addHighlightMenuItems(){return[{name:this.name,type:"text",priority:1e3,isActive:e=>W(e,this.schema.marks.bold),canActivate:e=>_t(e,this.schema.marks.bold),execute:this.commands.toggleBold,icon:this.editor.options.icons.bold,title:this.editor.options.messages.bold}]},addCommands(){return{toggleBold:Ot(this.schema.marks.bold)}},addKeyboardShortcuts(){return{"Mod-b":this.commands.toggleBold}},addInputRules(){return this.editor.options.markdownShortcuts?[xt({find:qt,type:this.schema.marks.bold}),xt({find:Rt,type:this.schema.marks.bold})]:[]},addPasteRules(){return this.editor.options.markdownShortcuts?[Dt({find:Lt,type:this.schema.marks.bold}),Dt({find:Pt,type:this.schema.marks.bold})]:[]}}),zt=P.create({name:"br",extendNodeSchema:()=>({br:{inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,leafText:()=>"\n",parseDOM:[{tag:"br"}],toDOM:()=>["br"]}}),addCommands(){return{setHardBreak:(e,t)=>t?.(e.tr.replaceSelectionWith(this.schema.nodes.br.create()))??!1}},addKeyboardShortcuts(){return{"Shift-Enter":J(Z,this.commands.setHardBreak)}}}),Bt=/(^|[^`])`([^`]+)`(?!`)/,$t=/(^|[^`])`([^`]+)`(?!`)/g,Vt=P.create({name:"code",extendMarkSchema:()=>({code:{excludes:"_",code:!0,exitable:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code",0]}}),addInputRules(){return[xt({find:Bt,type:this.schema.marks.code})]},addPasteRules(){return[Dt({find:$t,type:this.schema.marks.code})]}}),Ut=/^#\s$/,jt=P.create({name:"h3",extendNodeSchema:()=>({h3:{content:"inline*",group:"block",marks:"",parseDOM:[{tag:"h3"}],toD