UNPKG

medium-proeditor

Version:

A powerful & customizable Medium-style rich text editor

1 lines 120 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index-749207e7.js");function t(e=0,t=0,r=0){return Math.min(Math.max(e,t),r)}function r(r,n=null){if(!n)return null;const s=e.Selection.atStart(r),i=e.Selection.atEnd(r);if("start"===n||!0===n)return s;if("end"===n)return i;const o=s.from,a=i.to;return"all"===n?e.TextSelection.create(r,t(0,o,a),t(r.content.size,o,a)):e.TextSelection.create(r,t(n,o,a),t(n,o,a))}const n=e=>{const t=e.childNodes;for(let r=t.length-1;r>=0;r-=1){const s=t[r];3===s.nodeType&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?e.removeChild(s):1===s.nodeType&&n(s)}return e};function s(e){const t=`<body>${e}</body>`,r=(new window.DOMParser).parseFromString(t,"text/html").body;return n(r)}function i(t,r,n){if(t instanceof e.Node||t instanceof e.Fragment)return t;const o={slice:!0,parseOptions:{},...n},a="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return e.Fragment.fromArray(t.map((e=>r.nodeFromJSON(e))));const n=r.nodeFromJSON(t);return o.errorOnInvalidContent&&n.check(),n}catch(e){if(o.errorOnInvalidContent)throw new Error("[medium-proEditor error]: Invalid JSON content",{cause:e});return console.warn("[medium-proEditor warn]: Invalid content.","Passed value:",t,"Error:",e),i("",r,o)}if(a){if(o.errorOnInvalidContent){let n=!1,i="";const a=new e.Schema({topNode:r.spec.topNode,marks:r.spec.marks,nodes:r.spec.nodes.append({__medium__proeditor__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(n=!0,i="string"==typeof e?e:e.outerHTML,null)}]}})});if(o.slice?e.DOMParser.fromSchema(a).parseSlice(s(t),o.parseOptions):e.DOMParser.fromSchema(a).parse(s(t),o.parseOptions),o.errorOnInvalidContent&&n)throw new Error("[medium-proEditor error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const n=e.DOMParser.fromSchema(r);return o.slice?n.parseSlice(s(t),o.parseOptions).content:n.parse(s(t),o.parseOptions)}return i("",r,o)}function o(e,t,r={},n={}){return i(e,t,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}function a(t,r){const n=e.DOMSerializer.fromSchema(r).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function l(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 c(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(!c(e.content.child(n),{ignoreWhitespace:r,checkChildren:t}))return!1}return!0}return!1}const d={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>'},u={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 h={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:"'"},p={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},f="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),m="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),g=0;g<10;g++)h[48+g]=h[96+g]=String(g);for(g=1;g<=24;g++)h[g+111]="F"+g;for(g=65;g<=90;g++)h[g]=String.fromCharCode(g+32),p[g]=String.fromCharCode(g);for(var v in h)p.hasOwnProperty(v)||(p[v]=h[v]);const y="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function b(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);y?s=!0:r=!0}}return t&&(o="Alt-"+o),r&&(o="Ctrl-"+o),s&&(o="Meta-"+o),n&&(o="Shift-"+o),o}function w(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 E(e){let t=function(e){let t=Object.create(null);for(let r in e)t[b(r)]=e[r];return t}(e);return function(e,r){let n,s=function(e){var t=!(f&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||m&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?p:h)[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[w(s,r)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(r.shiftKey){let n=t[w(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=h[r.keyCode])&&n!=s){let s=t[w(n,r)];if(s&&s(e.state,e.dispatch,e))return!0}}return!1}}function k(e){return"string"!=typeof e?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):"true"===e||"false"!==e&&e}function A(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):k(r.getAttribute(e.name));null!=t&&(s[e.name]=t)}return{...n,...s}}}}function M(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 C=200,x=function(){};x.prototype.append=function(e){return e.length?(e=x.from(e),!this.length&&e||e.length<C&&this.leafAppend(e)||this.length<C&&e.leafPrepend(this)||this.appendInner(e)):this},x.prototype.prepend=function(e){return e.length?x.from(e).append(this):this},x.prototype.appendInner=function(e){return new N(this,e)},x.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?x.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},x.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},x.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)},x.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},x.from=function(e){return e instanceof x?e:e&&e.length?new S(e):x.empty};var S=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<=C)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=C)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}(x);x.empty=new S([]);var N=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}(x);class I{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 T(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 T(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 I(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 T(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>O&&(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 I(o.append(s),i)}remapping(t,r){let n=new e.Mapping;return this.items.forEach(((e,r)=>{let s=null!=e.mirrorOffset&&r-e.mirrorOffset>=t?n.maps.length-e.mirrorOffset:void 0;n.appendMap(e.map,s)}),t,r),n}addMaps(e){return 0==this.eventCount?this:new I(this.items.append(e.map((e=>new T(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 T(l,i,c))}else r.push(new T(l))}),n);let l=[];for(let e=t;e<i;e++)l.push(new T(s.maps[e]));let c=this.items.slice(0,n).append(l).append(r),d=new I(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 T(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 I(x.from(n.reverse()),s)}}I.empty=new I(x.empty,0);class T{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 T(t.getMap().invert(),t,this.selection)}}}class _{constructor(e,t,r,n,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=n,this.prevComposition=s}}const O=20;function D(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 q(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 L=!1,P=null;function R(e){let t=e.plugins;if(P!=t){L=!1,P=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){L=!0;break}}return L}const z=new e.PluginKey("history"),H=new e.PluginKey("closeHistory");function B(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new e.Plugin({key:z,state:{init:()=>new _(I.empty,I.empty,null,0,-1),apply:(e,r,n)=>function(e,t,r,n){let s,i=r.getMeta(z);if(i)return i.historyState;r.getMeta(H)&&(e=new _(e.done,e.undone,null,0,-1));let o=r.getMeta("appendedTransaction");if(0==r.steps.length)return e;if(o&&o.getMeta(z))return o.getMeta(z).redo?new _(e.done.addTransform(r,void 0,n,R(t)),e.undone,D(r.mapping.maps),e.prevTime,e.prevComposition):new _(e.done,e.undone.addTransform(r,void 0,n,R(t)),null,e.prevTime,e.prevComposition);if(!1===r.getMeta("addToHistory")||o&&!1===o.getMeta("addToHistory"))return(s=r.getMeta("rebased"))?new _(e.done.rebased(r,s),e.undone.rebased(r,s),q(e.prevRanges,r.mapping),e.prevTime,e.prevComposition):new _(e.done.addMaps(r.mapping.maps),e.undone.addMaps(r.mapping.maps),q(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?q(e.prevRanges,r.mapping):D(r.mapping.maps);return new _(e.done.addTransform(r,i?t.selection.getBookmark():void 0,n,R(t)),I.empty,a,r.time,null==s?e.prevComposition:s)}}(r,n,e,t)},config:t,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,n="historyUndo"==r?F:"historyRedo"==r?V:null;return!!n&&(t.preventDefault(),n(e.state,e.dispatch))}}}})}function $(e,t){return(r,n)=>{let s=z.getState(r);if(!s||0==(e?s.undone:s.done).eventCount)return!1;if(n){let i=function(e,t,r){let n=R(t),s=z.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 _(r?a:i.remaining,r?i.remaining:a,null,0,-1);return i.transform.setSelection(o).setMeta(z,{redo:r,historyState:l})}(s,r,e);i&&n(t?i.scrollIntoView():i)}return!0}}const F=$(!1,!0),V=$(!0,!0);function U(t){return function(r,n){let{$from:s,$to:i}=r.selection,o=s.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));return!!o&&(!n||(s.node(o.depth-1).type==t?function(t,r,n,s){let i=t.tr,o=s.end,a=s.$to.end(s.depth);o<a&&(i.step(new e.ReplaceAroundStep(o-1,a,o,a,new e.Slice(e.Fragment.from(n.create(null,s.parent.copy())),1,0),1,!0)),s=new e.NodeRange(i.doc.resolve(s.$from.pos),i.doc.resolve(a),s.depth));const l=e.liftTarget(s);if(null==l)return!1;i.lift(s,l);let c=i.doc.resolve(i.mapping.map(o,-1)-1);e.canJoin(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos);return r(i.scrollIntoView()),!0}(r,n,t,o):function(t,r,n){let s=t.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,r=n.startIndex;t>r;t--)e-=i.child(t).nodeSize,s.delete(e-1,e+1);let o=s.doc.resolve(n.start),a=o.nodeAfter;if(s.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=0==n.startIndex,c=n.endIndex==i.childCount,d=o.node(-1),u=o.index(-1);if(!d.canReplace(u+(l?0:1),u+1,a.content.append(c?e.Fragment.empty:e.Fragment.from(i))))return!1;let h=o.pos,p=h+a.nodeSize;return s.step(new e.ReplaceAroundStep(h-(l?1:0),p+(c?1:0),h+1,p-1,new e.Slice((l?e.Fragment.empty:e.Fragment.from(i.copy(e.Fragment.empty))).append(c?e.Fragment.empty:e.Fragment.from(i.copy(e.Fragment.empty))),l?0:1,c?0:1),l?0:1)),r(s.scrollIntoView()),!0}(r,n,o)))}}function j(t,r){const{tr:n}=t,{selection:s}=n,{ranges:i}=s;if(!r)return!0;for(const{$from:r,$to:s}of i)t.doc.nodesBetween(r.pos,s.pos,((t,r)=>{if(t.type.isText)return;const{doc:s,mapping:i}=n,o=s.resolve(i.map(r)),a=s.resolve(i.map(r+t.nodeSize)),l=o.blockRange(a);if(!l)return;const c=e.liftTarget(l);if(t.type.isTextblock){const{defaultType:e}=o.parent.contentMatchAt(o.index());n.setNodeMarkup(l.start,e)}null!==c&&n.lift(l,c)}));return r(n),!0}function W(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,u=o.pos-o.parentOffset,h=d&&1===c.parent.childCount?u===o.pos:e.Selection.atStart(s).from===a;return h&&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||!h&&l.textContent.length?!(!i||!l.type.isTextblock||l.textContent.length||!h||h&&"paragraph"===o.parent.type.name)&&j(t,r):j(t,r)}function K(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 G(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 J=(...e)=>(t,r,n)=>{for(const s of e)if(s?.(t,r,n))return!0;return!1},Z=(t,r)=>{const{tr:n}=t;return r&&r(n.setSelection(new e.AllSelection(n.doc))),!0};function Q({schema:t,commands:r}){const n="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,s={},i=J(G,W,e.deleteSelection,e.joinBackward,e.selectNodeBackward,K);s.Backspace=s["Mod-Backspace"]=s["Shift-Backspace"]=i;const o=J(e.deleteSelection,e.joinForward,e.selectNodeForward);var a,l;s["Mod-Delete"]=o,s.Enter=J(e.newlineInCode,t.nodes.listItem?(a=t.nodes.listItem,function(t,r){let{$from:n,$to:s,node:i}=t.selection;if(i&&i.isBlock||n.depth<2||!n.sameParent(s))return!1;let o=n.node(-1);if(o.type!=a)return!1;if(0==n.parent.content.size&&n.node(-1).childCount==n.indexAfter(-1)){if(3==n.depth||n.node(-3).type!=a||n.index(-2)!=n.node(-2).childCount-1)return!1;if(r){let s=e.Fragment.empty,i=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-i;t>=n.depth-3;t--)s=e.Fragment.from(n.node(t).copy(s));let o=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;s=s.append(e.Fragment.from(a.createAndFill()));let l=n.before(n.depth-(i-1)),c=t.tr.replace(l,n.after(-o),new e.Slice(s,4-i,0)),d=-1;c.doc.nodesBetween(l,c.doc.content.size,((e,t)=>{if(d>-1)return!1;e.isTextblock&&0==e.content.size&&(d=t+1)})),d>-1&&c.setSelection(e.Selection.near(c.doc.resolve(d))),r(c.scrollIntoView())}return!0}let c=s.pos==n.end()?o.contentMatchAt(0).defaultType:null,d=t.tr.delete(n.pos,s.pos),u=c?[l?{type:a,attrs:l}:null,{type:c}]:void 0;return!!e.canSplit(d.doc,n.pos,2,u)&&(r&&r(d.split(n.pos,2,u).scrollIntoView()),!0)}):null,e.createParagraphNear,e.liftEmptyBlock,e.splitBlock),s["Mod-Enter"]=J(e.newlineInCode,r.setHorizontalRule);const{listItem:c}=t.nodes;if(c){const t=U(c),n=function(t){return function(r,n){let{$from:s,$to:i}=r.selection,o=s.blockRange(i,(e=>e.childCount>0&&e.firstChild.type==t));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!=t)return!1;if(n){let s=c.lastChild&&c.lastChild.type==l.type,i=e.Fragment.from(s?t.create():null),a=new e.Slice(e.Fragment.from(t.create(null,e.Fragment.from(l.type.create(null,i)))),s?3:1,0),d=o.start,u=o.end;n(r.tr.step(new e.ReplaceAroundStep(d-(s?3:1),u,d,u,a,1,!0)).scrollIntoView())}return!0}}(c);s["Mod-["]=t,s["Shift-Tab"]=t,s["Mod-]"]=n,s.Tab=J(r.tabInCode,n)}else s.Tab=r.tabInCode;return s["Mod-a"]=Z,n&&(s["Ctrl-h"]=s["Alt-Backspace"]=i,s["Ctrl-d"]=s["Ctrl-Alt-Backspace"]=s["Alt-Delete"]=s["Alt-d"]=o,s["Ctrl-a"]=e.selectTextblockStart,s["Ctrl-e"]=e.selectTextblockEnd),s["Mod-z"]=F,s["Mod-Shift-z"]=s["Mod-y"]=V,s}class Y{find;handler;constructor(e){this.find=e.find,this.handler=e.handler}}const X=(t,r,n)=>{if(e.isRegExp(r))return[...t.matchAll(r)];return(r(t,n)??[]).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 ee({rules:t,commands:r}){let n=!1,s="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;return new e.Plugin({props:{handleDOMEvents:{paste:(e,t)=>{const r=t.clipboardData?.getData("text/html");return s=t,n=!!r?.includes("data-pm-slice"),!1}}},appendTransaction:(i,o,a)=>{if(!("paste"===i[0].getMeta("uiEvent")&&!n))return;const l=o.doc.content.findDiffStart(a.doc.content),c=o.doc.content.findDiffEnd(a.doc.content);return"number"==typeof l&&c&&l!==c.b?function({commands:t,state:r,from:n,to:s,rules:i,pasteEvent:o}){const a=r.tr,l=e.createChainableState({state:r,transaction:a});let c=!1;return r.doc.nodesBetween(n,s,((e,r)=>{if(!e.isTextblock||e.type.spec.code)return;const d=Math.max(n,r),u=Math.min(s,r+e.content.size),h=e.textBetween(d-r,u-r,void 0,"");for(const e of i)for(const r of X(h,e.find,o)){if(void 0===r.index)continue;const n=d+r.index+1,s=n+r[0].length,i={from:a.mapping.map(n),to:a.mapping.map(s)};null!==e.handler({commands:t,state:l,range:i,match:r,pasteEvent:o})&&(c=!0)}})),c&&a.steps.length?a:null}({rules:t,state:a,commands:r,from:Math.max(l-1,0),to:c.b-1,pasteEvent:s}):void 0}})}const te=new e.PluginKey("focus");const re="֑-߿יִ-﷽ﹰ-ﻼ",ne="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",se=new RegExp(`^[^${ne}]*[${re}]`),ie=new RegExp(`^[^${re}]*[${ne}]`);const oe=["h3","h4","paragraph"];const ae=new e.PluginKey("headlineSet");function le(t){return e.createElement("span",{className:"heading-label",attributes:{"data-heading-label":t}})}function ce(e,t){return t.from>=e.from&&t.to<=e.to}function de(t,r){const{doc:n}=t,s=[],i=[],o={};let a=null,l=!1,c=!1;const d=te.getState(t),u={from:d?.from??0,to:d?.to??0};return n.forEach(((t,n,d)=>{if(l)return;const h=t.type.name;if("paragraph"!==h||""!==t.textContent.trim()||a)if("h3"!==h||a&&"h3"===a.node.type.name)if("h4"!==h||a&&"h4"===a.node.type.name)l=!0;else{if("h3"===a?.node.type.name)return s.push(e.Decoration.node(n,n+t.nodeSize,{class:"subtitle"})),i.push(e.Decoration.widget(n+1,(()=>le(r.options.messages.subtitleLabel)))),o.subtitle=d,c||=ce(u,{from:n,to:n+t.nodeSize}),void(l=!0);a={node:t,pos:n,index:d}}else{if(s.push(e.Decoration.node(n,n+t.nodeSize,{class:"title"})),i.push(e.Decoration.widget(n+1,(()=>le(r.options.messages.titleLabel)))),o.title=d,c||=ce(u,{from:n,to:n+t.nodeSize}),"h4"===a?.node.type.name){const t={from:a.pos,to:a.pos+a.node.nodeSize};s.push(e.Decoration.node(t.from,t.to,{class:"kicker"})),i.push(e.Decoration.widget(t.from+1,(()=>le(r.options.messages.kickerLabel)))),o.kicker=a.index,c||=ce(u,t)}a={node:t,pos:n,index:d}}})),c&&s.push(...i),{decorations:e.DecorationSet.create(n,s),indexes:o}}function ue(t){return new e.Plugin({key:ae,state:{init:(e,r)=>de(r,t),apply:(e,r,n,s)=>de(s,t)},props:{decorations:t=>ae.getState(t)?.decorations??e.DecorationSet.empty}})}const he=new e.PluginKey("placeholders");function pe(t){const{messages:{titleLabel:r,mainPlaceholder:n,imgCaption:s,embedCaption:i}}=t.options,o=["paragraph","h3","h4"],a=["figcaption"],l=[...o,...a];let c=!0;function d({defaultMessage:e,childCount:t,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?s:i;if(o.includes(l.type.name)){if(1===t)return n;if(t<=2)return 0===a?r:n}return null}let u=!1;return new e.Plugin({key:he,state:{init:()=>({decorations:e.DecorationSet.empty,placeholders:new Map}),apply(t,s,i,h){const p=t.getMeta("removePlaceholder");p&&void 0!==p.pos&&s.placeholders.set(p.pos,!1);const f=t.getMeta("addPlaceholder");if(void 0!==f?.pos&&(s.placeholders.set(f.pos,{message:f.message,class:f.class}),f.removeOnAnyTr&&(c=!0)),!t.docChanged&&!s.placeholders.size&&!c)return s;const m=[],g=h.doc.childCount,v=i.doc.childCount;return h.doc.descendants(((t,c,h,p)=>{if(!l.includes(t.type.name))return!1;const f=s.placeholders.get(c);if(!1===f)return 1===p&&(u=!0),!1;if(f){const r=d({defaultMessage:f.message,childCount:g,index:p,node:t,parent:h});if(r)return m.push(e.Decoration.node(c,c+t.nodeSize,{"data-placeholder":r,class:f.class})),!1}if(!function({node:e,index:t}){return(a.includes(e.type.name)||t<=2&&o.includes(e.type.name))&&!e.textContent}({node:t,index:p}))return!1;let y=d({childCount:g,index:p,node:t,parent:h});if(1===g)y=n,u=!1;else if(2===g){if(0===p)y=r;else if(1===p&&v<=2){const e=p<i.doc.childCount&&i.doc.child(p)?.textContent!==t.textContent;y=!u||1===v||e?n:null}else y=null,u=!0;y===n&&(u=!1)}y&&m.push(e.Decoration.node(c,c+t.nodeSize,{"data-placeholder":y}))})),c&&!s.placeholders.size&&(c=!1),s.placeholders.clear(),{decorations:e.DecorationSet.create(h.doc,m),placeholders:s.placeholders}}},props:{decorations(e){return this.getState(e).decorations}}})}const fe=["paragraph","h3","h4","blockquote","pullquote"],me=new e.PluginKey("trailingNode");const ge=e.Feature.create({name:"core",priority:999,addGlobalAttributes:({options:t})=>[{types:e.uniqueIdTypes,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:oe,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 t=[B(),(r=this.editor,new e.Plugin({key:new e.PluginKey("editable"),props:{editable:()=>r.isEditable}})),(this.editor,new e.Plugin({key:te,state:{init:()=>({decorations:e.DecorationSet.empty,from:null,to:null}),apply(t,r){const{selection:n}=t,s=n.$head,i=s.node();if(!i)return{decorations:e.DecorationSet.empty,from:null,to:null};const o=s.depth>0?s.before(s.depth):0,a=o+i.nodeSize;return n.from>=o&&n.to<=a?{decorations:e.DecorationSet.create(t.doc,[e.Decoration.node(o,a,{class:"is-selected"})]),from:o,to:a}:{decorations:e.DecorationSet.empty,from:null,to:null}}},props:{decorations:e=>te.getState(e).decorations}})),ue(this.editor),new e.Plugin({key:me,appendTransaction:(e,t,r)=>{if(!me.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&&fe.includes(r.type.name))},apply:(e,t)=>{if(!e.docChanged)return t;const r=e.doc.lastChild;return!(r&&fe.includes(r.type.name))}}}),pe(this.editor),e.uniqueIdPlugin()];var r;return this.editor.options.autoTextDirection&&t.push(new e.Plugin({key:new e.PluginKey("textDirection"),appendTransaction:(t,{doc:r},{doc:n,tr:s})=>{if(!t.some((e=>!!e.docChanged))||r.eq(n))return;const i=e.combineTransactionSteps(r,t);for(const{newRange:t}of e.getChangedRanges(i)){const r=e.findChildrenInRange(n,t,(e=>oe.includes(e.type.name)));for(const{node:e,pos:t}of r){const r=0===(o=e.textContent).length?null:se.test(o)?"rtl":ie.test(o)?"ltr":null;r!==e.attrs.dir&&s.setNodeAttribute(t,"dir",r)}}var o;return i.steps.length?s:null}})),t}});function ve(...e){return t=>{for(const r of e)if(r(t))return!0;return!1}}function ye(t,r,n){const s=[];if(t===r){const r=n.resolve(t);for(const t of r.marks()){const n=e.getMarkRange(r,t.type);n&&s.push({mark:t,...n})}}else n.nodesBetween(t,r,((e,t)=>{if(e&&void 0!==e.nodeSize)for(const r of e.marks)s.push({from:t,to:t+e.nodeSize,mark:r})}));return s}function be(t){return new e.InputRule({find:t.find,handler:({state:r,range:n,match:s})=>{const i=e.callOrReturn(t.getAttributes,void 0,s);if(!1===i||null===i)return null;const{tr:o}=r,a=s[s.length-1],l=s[0];if(a){const e=l.search(/\S/),s=n.from+l.indexOf(a),c=s+a.length;if(ye(n.from,n.to,r.doc).filter((e=>e.mark.type.excluded.find((r=>r===t.type&&r!==e.mark.type)))).filter((e=>e.to>s)).length)return null;c<n.to&&o.delete(c,n.to),s>n.from&&o.delete(n.from+e,s);const d=n.from+e+a.length;o.addMark(n.from+e,d,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}function we(t){return new e.InputRule({find:t.find,handler:({state:r,range:n,match:s})=>{const i=e.callOrReturn(t.getAttributes,void 0,s)||{};console.log("Range",n),console.log("Attributes",i),console.log("Type",t.type);const o=r.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange();console.log("Block range",a);const l=a&&e.findWrapping(a,t.type,i);if(console.log("Wrapping",l),!l)return null;o.wrap(a,l);const c=o.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&e.canJoin(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(s,c))&&o.join(n.from-1)}})}const Ee=/^\s*>\s$/,ke=/^\s*>>\s$/,Ae=e.Feature.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:ve((t=>e.isNodeActive(t,this.schema.nodes.blockquote)),(t=>e.isNodeActive(t,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?[e.textblockTypeInputRule({find:Ee,type:this.schema.nodes.blockquote}),e.textblockTypeInputRule({find:ke,type:this.schema.nodes.pullquote})]:[]},addCommands:()=>({triggerCycleQuote:(t,r)=>{const{blockquote:n,pullquote:s,paragraph:i}=t.schema.nodes;return r&&function(t,r,n){for(let s=0;s<n.length;s++)if(e.isNodeActive(t,n[s])){const i=n[(s+1)%n.length];return void e.setBlockType(i)(t,r)}e.setBlockType(n[0])(t,r)}(t,r,[n,s,i]),!0}}),addKeyboardShortcuts(){return{"Mod-Alt-5":this.commands.triggerCycleQuote}}});function Me(t,r){const{selection:n}=t;let s=null;if(n instanceof e.TextSelection&&(s=n.$cursor),s){const e=t.storedMarks??s.marks();return!!r.isInSet(e)||!e.some((e=>e.type.excludes(r)))}const{ranges:i}=n;return i.some((({$from:e,$to:n})=>{let s=0===e.depth&&(t.doc.inlineContent&&t.doc.type.allowsMarkType(r));return t.doc.nodesBetween(e.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 Ce=(t,r={},n={})=>(s,i)=>{const{extendEmptyMarkRange:o=!1}=n;return e.isMarkActive(s,t,r)?e.unsetMark(t,{extendEmptyMarkRange:o})(s,i):e.setMark(t,r)(s,i)};function xe(t){return new Y({find:t.find,handler:({state:r,range:n,match:s,pasteEvent:i})=>{const o=e.callOrReturn(t.getAttributes,void 0,s,i);if(!1===o||null===o)return null;const{tr:a}=r,l=s[s.length-1],c=s[0];let d=n.to;if(l){const e=c.search(/\S/),s=n.from+c.indexOf(l),i=s+l.length;if(ye(n.from,n.to,r.doc).filter((e=>e.mark.type.excluded.find((r=>r===t.type&&r!==e.mark.type)))).filter((e=>e.to>s)).length)return null;i<n.to&&a.delete(i,n.to),s>n.from&&a.delete(n.from+e,s),d=n.from+e+l.length,a.addMark(n.from+e,d,t.type.create(o||{})),a.removeStoredMark(t.type)}}})}const Se=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ne=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ie=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Te=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,_e=e.Feature.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:t=>e.isMarkActive(t,this.schema.marks.bold),canActivate:e=>Me(e,this.schema.marks.bold),execute:this.commands.toggleBold,icon:this.editor.options.icons.bold,title:this.editor.options.messages.bold}]},addCommands(){return{toggleBold:Ce(this.schema.marks.bold)}},addKeyboardShortcuts(){return{"Mod-b":this.commands.toggleBold}},addInputRules(){return this.editor.options.markdownShortcuts?[be({find:Se,type:this.schema.marks.bold}),be({find:Ie,type:this.schema.marks.bold})]:[]},addPasteRules(){return this.editor.options.markdownShortcuts?[xe({find:Ne,type:this.schema.marks.bold}),xe({find:Te,type:this.schema.marks.bold})]