import{r as i,c as t,h as o,H as s}from"./p-c1e62c18.js";const n=class{constructor(o){i(this,o),this.change=t(this,"change",7),this.enterKeyDown=t(this,"enterKeyDown",7),this.lastBackspaceKeyDown=t(this,"lastBackspaceKeyDown",7),this.arrowDown=t(this,"arrowDown",7),this.arrowUp=t(this,"arrowUp",7),this.isContentCleared=!1}componentShouldUpdate(i){return this.input.innerHTML!==i.text}async focusOnInput(){this.input.focus(),function(i){if(i.focus(),void 0!==window.getSelection&&void 0!==document.createRange){const t=document.createRange();t.selectNodeContents(i),t.collapse(!1);const o=window.getSelection();o.removeAllRanges(),o.addRange(t)}else if(void 0!==document.body.createTextRange){const t=document.body.createTextRange();t.moveToElementText(i),t.collapse(!1),t.select()}}(this.input)}render(){const i=this.type||"h1";return o(s,null,o(i,{ref:i=>this.input=i,id:`${i}-${this.id}`,key:`${i}-${this.id}`,contenteditable:!0,onInput:i=>{const t=i.target.innerHTML;this.change.emit({id:this.id,value:{text:t}}),0===t.length&&setTimeout((()=>this.isContentCleared=!0),100)},onKeyDown:i=>{"Enter"===i.key?(i.preventDefault(),this.enterKeyDown.emit(i)):"Backspace"===i.key&&this.isContentCleared?this.lastBackspaceKeyDown.emit(i):"ArrowDown"===i.key?this.value.text.length===window.getSelection().getRangeAt(0).endOffset&&this.arrowDown.emit(i):"ArrowUp"===i.key&&0===window.getSelection().getRangeAt(0).endOffset&&this.arrowUp.emit(i)}},this.value.text))}};n.style="dvn-rich-editor-heading-block{display:block;flex:1}dvn-rich-editor-heading-block h1{font-size:2rem;margin:0;display:block}dvn-rich-editor-heading-block h2{font-size:1.6rem;margin:0;display:block}dvn-rich-editor-heading-block h3{font-size:1.2rem;margin:0;display:block}";export{n as dvn_rich_editor_heading_block}