Your IP : 3.145.59.167


Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/fileman/html_editor/
Upload File :
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/fileman/html_editor/html-views.min.js

(function(){function e(e,t,i){this.editor=e;this.element=t;this.container=i;this.config=e.config||{};this.isShown=null;this.bbCode=e.bbCode;BX.addCustomEvent(this.editor,"OnClickBefore",BX.proxy(this.OnClick,this))}e.prototype={Focus:function(){if(!document.querySelector||this.element.ownerDocument.querySelector(":focus")===this.element)return;try{this.element.focus()}catch(e){}},Hide:function(){this.isShown=false;this.container.style.display="none"},Show:function(){this.isShown=true;this.container.style.display=""},Disable:function(){this.element.setAttribute("disabled","disabled")},Enable:function(){this.element.removeAttribute("disabled")},OnClick:function(e){},IsShown:function(){return!!this.isShown}};function t(e,t,i){o.superclass.constructor.apply(this,arguments);this.name="textarea";this.InitEventHandlers();if(!this.element.value&&this.editor.config.content)this.SetValue(this.editor.config.content,false)}BX.extend(t,e);t.prototype.Clear=function(){this.element.value=""};t.prototype.GetValue=function(e){var t=this.IsEmpty()?"":this.element.value;if(e){t=this.parent.parse(t)}return t};t.prototype.SetValue=function(e,t,i){if(t){e=this.editor.Parse(e,true,i)}this.editor.dom.pValueInput.value=this.element.value=e};t.prototype.SaveValue=function(){if(this.editor.inited){this.editor.dom.pValueInput.value=this.element.value}};t.prototype.HasPlaceholderSet=function(){var e=this.element.getAttribute("placeholder")||null,t=this.element.value;return!t||t===e};t.prototype.IsEmpty=function(){var e=BX.util.trim(this.element.value);return e===""||this.HasPlaceholderSet()};t.prototype.InitEventHandlers=function(){var e=this;BX.bind(this.element,"focus",(function(){e.editor.On("OnTextareaFocus");e.isFocused=true}));BX.bind(this.element,"blur",(function(){e.editor.On("OnTextareaBlur");e.isFocused=false}));BX.bind(this.element,"keydown",(function(t){e.editor.textareaKeyDownPreventDefault=false;if((t.ctrlKey||t.metaKey)&&!t.altKey&&t.keyCode===e.editor.KEY_CODES["enter"]){e.editor.On("OnCtrlEnter",[t,e.editor.GetViewMode()]);return BX.PreventDefault(t)}e.editor.On("OnTextareaKeydown",[t]);if(e.editor.textareaKeyDownPreventDefault)return BX.PreventDefault(t)}));BX.bind(this.element,"keyup",(function(t){e.editor.On("OnTextareaKeyup",[t])}))};t.prototype.IsFocused=function(){return this.isFocused};t.prototype.ScrollToSelectedText=function(e){};t.prototype.SelectText=function(e){var t=this.element.value,i=t.indexOf(e);if(i!=-1){this.element.focus();this.element.setSelectionRange(i,i+e.length)}};t.prototype.GetTextSelection=function(){var e=false;if(this.element.selectionStart!=undefined){e=this.element.value.substr(this.element.selectionStart,this.element.selectionEnd-this.element.selectionStart)}else if(document.selection&&document.selection.createRange){e=document.selection.createRange().text}else if(window.getSelection){e=window.getSelection();e=e.toString()}return e};t.prototype.WrapWith=function(e,t,i){if(!e)e="";if(!t)t="";if(!i)i="";if(e.length<=0&&t.length<=0&&i.length<=0)return true;var o=!!i,n=this.GetTextSelection(),s=n?"select":o?"after":"in";if(o){i=e+i+t}else if(n){i=e+n+t}else{i=e+t}if(this.element.selectionStart!=undefined){var r=this.element.scrollTop,a=this.element.selectionStart,l=this.element.selectionEnd;this.element.value=this.element.value.substr(0,a)+i+this.element.value.substr(l);if(s=="select"){this.element.selectionStart=a;this.element.selectionEnd=a+i.length}else if(s=="in"){this.element.selectionStart=this.element.selectionEnd=a+e.length}else{this.element.selectionStart=this.element.selectionEnd=a+i.length}this.element.scrollTop=r}else if(document.selection&&document.selection.createRange){var d=document.selection.createRange();var h=d.duplicate();i=i.replace(/\r?\n/g,"\n");d.text=i;d.setEndPoint("StartToStart",h);d.setEndPoint("EndToEnd",h);if(s=="select"){d.collapse(true);i=i.replace(/\r\n/g,"1");d.moveEnd("character",i.length)}else if(s=="in"){d.collapse(false);d.moveEnd("character",e.length);d.collapse(false)}else{d.collapse(false);d.moveEnd("character",i.length);d.collapse(false)}d.select()}else{this.element.value+=i}return true};t.prototype.GetCursorPosition=function(){return this.element.selectionStart};class i{copilotParams={};copilotLoaded=false;selectionTypeCaret="Caret";resultNodeAttr="bxhtmled-copilot-result-node";resultColor="#8d52ec";invitationLineModes={NONE:"none",LAST_LINE:"lastLine",EACH_LINE:"eachLine"};invitationLineMode=this.invitationLineModes.LAST_LINE;constructor(e,t={}){this.iframeView=e;this.iframeContainer=e.container;this.contentEditable=e.element;this.copilotParams=t;this.invitationLineMode=t.invitationLineMode??this.invitationLineModes.LAST_LINE;this.invitationLine=this.renderInvitationLine();this.invitationLineAbsolute=this.renderInvitationLine();this.insertResultNode=this.renderInsertResultNode();this.copilot=new BX.AI.Copilot({moduleId:t.moduleId,contextId:t.contextId,category:t.category,contextParameters:t.contextParameters,autoHide:true,preventAutoHide:e=>this.iframeContainer.contains(e.target)});this.bindHandlers();this.copilot.init()}renderInvitationLine(){let e=BX.message("BXEdCopilotPlaceholder_MSGVER_2");if(this.copilotParams.isMentionUnavailable){e=BX.message("BXEdCopilotPlaceholderWithoutMention_MSGVER_1")}return BX.Tag.render`
			<div class="bxhtmled-copilot" placeholder="${e}"></div>
		`}renderInsertResultNode(){return BX.Tag.render`
			<span class="bxhtmled-insert-result"></span>
		`}bindHandlers(){this.copilot.subscribe("finish-init",this.finishInitHandler.bind(this));this.copilot.subscribe("aiResult",this.aiResultHandler.bind(this));this.copilot.subscribe("save",this.saveHandler.bind(this));this.copilot.subscribe("add_below",this.addBelowHandler.bind(this));this.copilot.subscribe("cancel",this.cancelHandler.bind(this));this.copilot.subscribe("hide",this.saveResultNodes.bind(this));document.addEventListener("click",this.documentClickHandler.bind(this));document.addEventListener("keydown",this.onWindowKeyDownHandler.bind(this));this.contentEditable.addEventListener("input",this.onContentEditableKeyDown.bind(this));window.addEventListener("scroll",this.onScrollHandler.bind(this),true);new ResizeObserver(this.onScrollHandler.bind(this)).observe(this.contentEditable);window.addEventListener("resize",this.handleResizeWindow.bind(this));BX.addCustomEvent(window,"onPullEvent-unicomments",this.startAdjustAnimation.bind(this));this.hideObserver=new MutationObserver((()=>{if(this.iframeContainer.offsetHeight<=0){this.hideInvitationLine();this.hideObserver.disconnect()}}));this.hideObserver.observe(document.body,{childList:true})}documentClickHandler(e){if(!this.iframeContainer.contains(e.target)){this.hideInvitationLine()}}startAdjustAnimation(){this.animation?.stop();this.animation=new BX.easing({duration:1e3,start:{},finish:{},transition:BX.easing.makeEaseOut(BX.easing.transitions.linear),step:()=>{if(this.copilot.isShown()){this.copilot.adjust(this.getAdjustOptionsForRect(this.adjustmentRect))}if(this.copilotBtnPopup?.isShown()){this.adjustCopilotButton(this.getAdjustOptionsForRectSpaced(this.adjustmentRect,true))}},complete:()=>this.animation=null});this.animation.animate()}finishInitHandler(){this.copilotLoaded=true;this.updateInvitationLine()}aiResultHandler(e){const t=this.getResultNodes();let i;if(t.length!==0){i=[...t].pop();i.innerText=e.data.result}else{i=this.getSpanWithText(e.data.result);BX.Dom.style(i,"color",this.resultColor);BX.Dom.attr(i,this.resultNodeAttr,"true");if(this.invitationLineMode===this.invitationLineModes.LAST_LINE){this.insertResultNode.after(BX.Tag.render`<br>`)}this.insertResultNode.after(i);this.insertResultNode.remove()}this.iframeView.ScrollToInsertedText();this.getSelection().removeAllRanges();this.copilot.adjust(this.getAdjustOptions(i))}saveHandler(e){if(this.getResultNodes().length===0){const t=this.getSelection().getRangeAt(0);const i=this.getSpanWithText(e.data.result);t.deleteContents();t.insertNode(i);this.iframeView.UpdateHeight()}this.saveResultNodes();this.iframeView.editor.synchro.FromIframeToTextarea(true,true);this.iframeView.editor.synchro.FromTextareaToIframe(true);this.copilot.hide()}addBelowHandler(e){const t=this.getSpanWithText(e.data.result);let i=null;if(this.getSelectionText()!==""){i=this.getSelection().getRangeAt(0).endContainer}const o=i===this.iframeView.element;if(i&&!o){i.after(t);i.after(BX.Tag.render`<br>`)}else{BX.Dom.append(BX.Tag.render`<br>`,this.contentEditable);BX.Dom.append(t,this.contentEditable);BX.Dom.append(BX.Tag.render`<br>`,this.contentEditable)}this.iframeView.ScrollToInsertedText();this.getSelection().removeAllRanges();this.iframeView.editor.synchro.FromIframeToTextarea(true,true);this.iframeView.editor.synchro.FromTextareaToIframe(true);this.copilot.hide()}cancelHandler(){[...this.getResultNodes()][0]?.before(this.insertResultNode);this.removeResultNodes();if(this.showRect){this.copilot.adjust(this.getAdjustOptionsForRect(this.showRect))}}getSpanWithText(e){const t=BX.Dom.create("span");t.innerText=e;return t}onWindowKeyDownHandler(e){if(e.key==="Escape"){this.copilot.hide()}}handleResizeWindow(){this.copilot.adjustWidth(this.getCopilotWidth())}removeResultNodes(){this.getResultNodes().forEach((e=>e.remove()))}saveResultNodes(){for(const e of this.getResultNodes()){for(const t of e.childNodes){e.before(t.cloneNode(true))}e.remove()}}onContentEditableMouseDown(){this.insertResultNode.remove();this.hideInvitationLine();this.hideCopilotButton()}onIframeWindowClick(){this.update()}onContentEditableKeyDown(){this.insertResultNode.remove();this.updatePopup();this.hideInvitationLine();this.hideCopilotButton()}onContentEditableKeyUp(e){if(e.key===" "){return}this.update()}onScrollHandler(){if(this.contentEditable.offsetHeight<=0){return}if(this.invitationLineAbsolute.parentNode){this.showInvitationLine()}if(this.copilotBtnPopup?.isShown()&&this.getSelectionText()!==""){const e=this.getSelection().getRangeAt(0);this.adjustCopilotButton(this.getAdjustOptions(e,true))}if(this.copilot.isShown()&&this.getSelectionText()!==""){const e=this.getSelection().getRangeAt(0);this.copilot.adjust(this.getAdjustOptions(e));return}if(this.getResultNodes().pop()){this.updatePopup()}else if(this.adjustmentRect){this.copilot.adjust(this.getAdjustOptionsForRect(this.adjustmentRect))}}onContentEditableBlur(){setTimeout((()=>{this.hideInvitationLine()}),0)}onIframeFocus(){setTimeout((()=>{this.updateInvitationLine()}),0)}shouldBeShown(){return this.invitationLineAbsolute.offsetWidth!==0&&!this.copilot.isShown()}show(e=false){this.copilot.setContext(this.contentEditable.innerText);this.insertResultNode.remove();this.getSelection().getRangeAt(0).insertNode(this.insertResultNode);const t={top:parseInt(this.invitationLineAbsolute.style.top),left:parseInt(this.invitationLineAbsolute.style.left)};if(e){t.top+=28}const i=this.iframeContainer.getBoundingClientRect();this.adjustmentRect={bottom:t.top-i.y-window.scrollY,x:t.left-i.x-window.scrollX,width:0};this.showRect=this.adjustmentRect;this.copilot.show({bindElement:t,showFromSpace:e,width:this.getCopilotWidth()});this.hideInvitationLine()}showAtTheBottom(){this.copilot.setContext(this.contentEditable.innerText);this.insertResultNode.remove();let e;let t;if(this.needToAppendEmptyElement()){e=BX.Tag.render`<br>`;t=BX.Tag.render`<div></div>`;const i=this.getFilteredChildNodes(this.contentEditable).pop();if(this.contentEditable.innerText!==""&&i?.tagName!=="BR"){this.contentEditable.append(BX.Tag.render`<br>`)}this.contentEditable.append(e);this.contentEditable.append(t)}const i=this.getFilteredChildNodes(this.contentEditable).pop();const o=this.getAdjustOptions(i).position;t?.remove();this.showRect=this.adjustmentRect;if(e){e.before(this.insertResultNode)}else{this.contentEditable.append(this.insertResultNode)}this.copilot.show({bindElement:o,width:this.getCopilotWidth()});this.hideInvitationLine()}needToAppendEmptyElement(){const e=this.contentEditable.innerText;return!e||e.at(-1)!=="\n"||e.at(-2)&&e.at(-2)!=="\n"}update(){this.updateCopilotButton();this.updatePopup();this.updateInvitationLine()}updateCopilotButton(){const e=!this.copilot.isShown()&&this.getSelectionText()!=="";if(e&&!this.copilotBtnPopup?.isShown()&&this.copilotLoaded){this.showCopilotButton()}if(!e){this.hideCopilotButton()}}showCopilotButton(){if(!this.copilotBtnPopup){this.copilotBtnPopup=new BX.Main.Popup({bindElement:this.contentEditable,padding:6,borderRadius:"6px",content:this.renderCopilotButton(),autoHide:true})}this.copilotBtnPopup.setMaxWidth(null);this.copilotBtnPopup.setMinWidth(null);this.copilotBtnPopup.setPadding(6);this.adjustCopilotButton(this.getAdjustOptions(this.getSelection().getRangeAt(0),true));this.copilotBtnPopup.adjustPosition();this.copilotBtnPopup.show();setTimeout((()=>this.updateCopilotButton()),0)}renderCopilotButton(){BX.Runtime.loadExtension("ui.icon-set.main");this.copilotButton=BX.Tag.render`
			<button class="bxhtmled-copilot-btn" onclick="${this.copilotButtonClickHandler.bind(this)}">
				<div class="bxhtmled-copilot-btn-icon ui-icon-set --copilot-ai"></div>
				${BX.message("BXEdCopilotButtonText")}
			</button>
		`;return this.copilotButton}copilotButtonClickHandler(){const e=this.getAdjustOptions(this.getSelection().getRangeAt(0));this.copilot.setSelectedText(this.getSelection().toString());this.copilot.show({bindElement:e.position,showFromPopup:true,width:this.getCopilotWidth()});this.hideCopilotButton()}adjustCopilotButton(e){if(e.hide){this.copilotBtnPopup.setMaxWidth(0);this.copilotBtnPopup.setMinWidth(0);this.copilotBtnPopup.setPadding(0)}else{this.copilotBtnPopup.setMaxWidth(null);this.copilotBtnPopup.setMinWidth(null);this.copilotBtnPopup.setPadding(6);this.copilotBtnPopup.setBindElement(e.position);this.copilotBtnPopup.adjustPosition()}}getCopilotWidth(){return this.contentEditable.offsetWidth-30}hideCopilotButton(){this.copilotBtnPopup?.close()}updatePopup(){if(!this.copilot.isShown()){return}const e=this.getResultNodes().pop();if(!this.isNotFocusedOrCursorAtResultNode(this.getSelection())||!e){this.copilot.hide();return}this.copilot.adjust(this.getAdjustOptions(e))}getAdjustOptions(e,t=false){const i=e.getBoundingClientRect();return this.getAdjustOptionsForRectSpaced(i,t)}getAdjustOptionsForRectSpaced(e,t=false){const i=this.getAdjustOptionsForRect(e,t);i.position.top+=10;return i}getAdjustOptionsForRect(e,t=false){this.adjustmentRect=e;const i=this.iframeContainer.getBoundingClientRect();return{hide:e.bottom>this.iframeView.document.documentElement.offsetHeight+13||e.bottom+13<0,position:{top:e.bottom+i.y+window.scrollY,left:e.x+i.x+t*(e.width/2-55)+window.scrollX}}}isNotFocusedOrCursorAtResultNode(e){if(!e.focusNode){return true}return this.getResultNodes().filter((t=>e.focusNode===t||e.focusNode.parentElement===t)).length}getResultNodes(){return[...this.contentEditable.querySelectorAll(`[${this.resultNodeAttr}=true]`)]}updateInvitationLine(){this.insertResultNode.remove();if(this.shouldShowInvitationLine()&&this.copilotLoaded){this.showInvitationLine()}else{this.hideInvitationLine()}}showInvitationLine(){const e=this.getSelection();if(e.rangeCount===0){return false}const t=this.getFilteredChildNodes(this.contentEditable).pop();if(this.isZwnbspNode(t)){t.replaceWith(BX.Tag.render`<br>`)}const i=e.getRangeAt(0);i.insertNode(this.invitationLine);const o=this.iframeContainer.getBoundingClientRect();const n={top:this.invitationLine.offsetTop+o.y-this.contentEditable.parentElement.scrollTop+window.scrollY,left:this.invitationLine.offsetLeft+o.x+window.scrollX,width:this.invitationLine.offsetWidth};this.invitationLineAbsolute.style.top=`${n.top}px`;this.invitationLineAbsolute.style.left=`${n.left}px`;this.invitationLineAbsolute.style.width=`${n.width}px`;this.invitationLineAbsolute.style.display="";this.hideInvitationLine();document.body.append(this.invitationLineAbsolute);if(!this.invitationLineAbsolute.registered){BX.ZIndexManager.register(this.invitationLineAbsolute);BX.ZIndexManager.bringToFront(this.invitationLineAbsolute);this.invitationLineAbsolute.registered=true}if(!this.shouldDisplayInvitationLine()){this.invitationLineAbsolute.style.display="none"}}shouldDisplayInvitationLine(){const e=this.iframeContainer.getBoundingClientRect();const t=this.invitationLineAbsolute.getBoundingClientRect();return t.bottom+20<e.bottom&&t.top>e.top}hideInvitationLine(){this.invitationLine.remove();this.invitationLineAbsolute.remove()}getSelectionText(){return this.getSelection().toString().replaceAll("\n","").trim()}getSelection(){return this.iframeView.GetSelection()}shouldShowInvitationLine(){if(!this.iframeContainer.contains(document.activeElement)){return false}if(this.invitationLineMode===this.invitationLineModes.NONE){return false}if(this.invitationLineMode===this.invitationLineModes.EACH_LINE){return this.isCursorAtStartOfLine(this.getSelection())}return this.isCursorAtNewLine(this.getSelection())}isCursorAtStartOfLine(e){if(e.type!==this.selectionTypeCaret){return false}this.removeZwnbspSequence();const t=e.getRangeAt(0);const i=parseInt(getComputedStyle(this.contentEditable).paddingLeft);if(t.getBoundingClientRect().x>i){return false}const o=BX.Tag.render`<span style="width: 10px; height: 10px;"></span>`;t.insertNode(o);const n=o.previousSibling;const s=o.nextSibling;const r=o.getBoundingClientRect().x-i;if(e.focusNode===this.contentEditable&&s===null&&(n?.tagName==="DIV"||this.isZwnbspNode(n))){if(this.isZwnbspNode(n)){if(!n.nextSibling){n.replaceWith(BX.Tag.render`<br>`)}else{n.remove()}}o.remove();return false}const a=!n||this.doesNodeMakeLine(n)||o.nodeName!=="#text"&&o.textContent==="";const l=!s||this.doesNodeMakeLine(s)&&s.tagName!=="TABLE";const d=r<=0;o.remove();return(a&&l||this.isZwnbspNode(n)&&s?.nodeName==="#text")&&d}isCursorAtNewLine(e){if(e.toString()!==""){return false}this.removeZwnbspSequence();if(e.focusNode.outerHTML==="<span><br></span>"||e.focusNode.outerHTML==="<div><br></div>"){e.focusNode.replaceWith(BX.Tag.render`<br>`)}const t=this.getFilteredChildNodes(this.contentEditable);const i=t.length===0||t.length===1&&t[0].tagName==="BR";const o=t.pop();let n=false;if(o?.tagName==="SPAN"){const e=this.getFilteredChildNodes(o);const t=e.pop();const i=e.pop();n=this.doesNodeMakeLine(i)&&this.doesNodeMakeLine(t)}if(!this.isZwnbspNode(e.focusNode)&&e.focusNode!==this.contentEditable&&o?.tagName!=="SPAN"){return false}const s=t.pop();const r=this.doesNodeMakeLine(s)&&this.doesNodeMakeLine(o)&&o?.tagName!=="BLOCKQUOTE";return(i||r||n)&&this.isCursorAtTheEndOfDocument(e)}removeZwnbspSequence(){const e=[];this.contentEditable.childNodes.forEach((t=>{if(this.isZwnbspNode(t)&&this.isZwnbspNode(t.nextSibling)){e.push(t)}}));e.forEach((e=>e.remove()));if(this.contentEditable.innerHTML===this.createZwnbspNode().innerHTML){this.contentEditable.innerHTML=""}}getFilteredChildNodes(e){return[...e.childNodes].filter((e=>e.nodeName!=="#text"||this.isZwnbspNode(e)||e.textContent!==""))}doesNodeMakeLine(e){if(!e){return false}if(e.outerHTML==="<span><br></span>"){e.replaceWith(BX.Tag.render`<br>`);return true}if(this.isZwnbspNode(e)){if(!e.nextSibling){e.replaceWith(BX.Tag.render`<br>`)}else{e.remove()}return true}const t=["BR","UL","OL","PRE","TABLE","DIV","P","BLOCKQUOTE"];if(e.tagName==="SPAN"){return this.doesNodeMakeLine(this.getFilteredChildNodes(e).pop())}return t.includes(e.tagName)||t.includes([...e.childNodes].pop()?.tagName)}isZwnbspNode(e){if(!e){return false}return BX.Tag.render`<div>${e.cloneNode()}</div>`.innerHTML===this.createZwnbspNode().innerHTML}createZwnbspNode(){return BX.Tag.render`<div>&#XFEFF;</div>`}isCursorAtTheEndOfDocument(e){const t=e.focusOffset;const i=e.focusNode;e.modify("move","forward","character");if(t===e.focusOffset&&i===e.focusNode){return true}else{e.modify("move","backward","character");return false}}}function o(e,t,i){o.superclass.constructor.apply(this,arguments);this.name="wysiwyg";this.caretNode="<br>"}BX.extend(o,e);o.prototype.OnCreateIframe=function(){this.document=this.editor.sandbox.GetDocument();this.element=this.document.body;this.editor.document=this.document;this.textarea=this.editor.dom.textarea;this.isFocused=false;this.InitEventHandlers();window.rangy.init();if(this.config.isCopilotEnabled&&BX.AI?.Copilot){this.copilot=new i(this,{...this.config.copilotParams,isMentionUnavailable:this.config.isMentionUnavailable})}this.Enable()};o.prototype.setCopilotContextParameters=function(e){this.config.copilotParams.contextParameters={xmlId:e[0],entityId:e[1]}};o.prototype.ScrollToInsertedText=function(){this.document.documentElement.scrollTop=this.document.documentElement.scrollHeight;this.UpdateHeight()};o.prototype.UpdateHeight=function(){this.editor.UpdateHeight()};o.prototype.GetSelection=function(){return this.document.getSelection()};o.prototype.isCopilotInitialized=function(){return this.copilot&&this.copilot.copilotLoaded};o.prototype.Clear=function(){this.element.innerHTML=this.caretNode};o.prototype.GetValue=function(e,t){this.iframeValue=this.IsEmpty()?"":this.editor.GetInnerHtml(this.element);this.iframeValue=this.iframeValue.replaceAll(/<span style="font-family: var\(--ui-font-family-primary, var\(--ui-font-family-helvetica\)\);">(.*?)<\/span>/g,"$1");this.iframeValue=this.iframeValue.replace(/<span class="bxhtmled-insert-result"><\/span>/g,"");this.editor.On("OnIframeBeforeGetValue",[this.iframeValue]);if(e){this.iframeValue=this.editor.Parse(this.iframeValue,false,t)}return this.iframeValue};o.prototype.SetValue=function(e,t){if(t){e=this.editor.Parse(e)}this.element.innerHTML=e;this.CheckContentLastChild(this.element);this.editor.On("OnIframeSetValue",[e])};o.prototype.Show=function(){this.isShown=true;this.container.style.display="";this.ReInit()};o.prototype.ReInit=function(){this.Disable();this.Enable();this.editor.On("OnIframeReInit")};o.prototype.Hide=function(){this.isShown=false;this.container.style.display="none"};o.prototype.Disable=function(){this.element.removeAttribute("contentEditable")};o.prototype.Enable=function(){this.element.setAttribute("contentEditable","true")};o.prototype.Focus=function(e){if(BX.browser.IsIE()&&this.HasPlaceholderSet()){this.Clear()}if(!document.querySelector||this.element.ownerDocument.querySelector(":focus")!==this.element||!this.IsFocused()){if(BX.browser.IsIOS()){var t=this;if(this.focusTimeout)clearTimeout(this.focusTimeout);this.focusTimeout=setTimeout((function(){var e=document.documentElement.scrollTop||document.body.scrollTop,i=document.documentElement.scrollLeft||document.body.scrollLeft;BX.focus(t.element);window.scrollTo(i,e)}),200)}else{BX.focus(this.element)}}if(e&&this.element.lastChild){if(this.element.lastChild.nodeName==="BR"){this.editor.selection.SetBefore(this.element.lastChild)}else{this.editor.selection.SetAfter(this.element.lastChild)}}};o.prototype.SetFocusedFlag=function(e){this.isFocused=e};o.prototype.IsFocused=function(){return this.isFocused};o.prototype.GetTextContent=function(e){var t=this.editor.util.GetTextContent(this.element);return e===true?t.replace(/\uFEFF/gi,""):t};o.prototype.HasPlaceholderSet=function(){return this.textarea&&this.GetTextContent()==this.textarea.getAttribute("placeholder")};o.prototype.IsEmpty=function(e){if(!document.querySelector)return false;var t=this.element.innerHTML,i="blockquote, ul, ol, img, embed, object, table, iframe, svg, video, audio, button, input, select, textarea";return t===""||t===this.caretNode||this.HasPlaceholderSet()||this.GetTextContent(e)===""&&!this.element.querySelector(i)};o.prototype._initObjectResizing=function(){var e=["width","height"],t=e.length,i=this.element;this.commands.exec("enableObjectResizing",this.config.allowObjectResizing);if(this.config.allowObjectResizing){if(browser.supportsEvent("resizeend")){dom.observe(i,"resizeend",(function(o){var n=o.target||o.srcElement,s=n.style,r=0,a;for(;r<t;r++){a=e[r];if(s[a]){n.setAttribute(a,parseInt(s[a],10));s[a]=""}}redraw(i)}))}}else{if(browser.supportsEvent("resizestart")){dom.observe(i,"resizestart",(function(e){e.preventDefault()}))}}};var n=function(e){if(e.setActive){try{e.setActive()}catch(e){}}else{var t=e.style,i=doc.documentElement.scrollTop||doc.body.scrollTop,o=doc.documentElement.scrollLeft||doc.body.scrollLeft,n={position:t.position,top:t.top,left:t.left,WebkitUserSelect:t.WebkitUserSelect};dom.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(e);e.focus();dom.setStyles(n).on(e);if(win.scrollTo){win.scrollTo(o,i)}}};o.prototype.InitEventHandlers=function(){var e=this,t=this.editor,i=this.GetValue(),o=this.element,n=this.editor.sandbox.GetWindow(),s=!BX.browser.IsOpera()?o:this.editor.sandbox.GetWindow();if(this._eventsInitedObject&&this._eventsInitedObject===s)return;this._eventsInitedObject=s;BX.bind(s,"focus",(function(){t.On("OnIframeFocus");e.isFocused=true;if(i!==e.GetValue()){BX.onCustomEvent(t,"OnIframeChange")}e.copilot?.onIframeFocus()}));BX.bind(s,"blur",(function(){t.On("OnIframeBlur");e.isFocused=false;setTimeout((function(){i=e.GetValue()}),0);e.copilot?.onContentEditableBlur()}));BX.bind(s,"contextmenu",(function(i){if(i&&!i.ctrlKey&&!i.shiftKey&&BX.getEventButton(i)&BX.MSRIGHT){t.On("OnIframeContextMenu",[i,i.target||i.srcElement,e.contMenuRangeCollapsed])}}));BX.bind(s,"mousedown",(function(i){var o=t.selection.GetRange(),n=i.target||i.srcElement,s=t.GetBxTag(n);e.contMenuRangeCollapsed=o&&o.collapsed;if(t.synchro.IsSyncOn()){t.synchro.StopSync()}if(BX.browser.IsIE10()||BX.browser.IsIE11()){t.phpParser.RedrawSurrogates()}if(n.nodeName=="BODY"||!t.phpParser.CheckParentSurrogate(n)){setTimeout((function(){o=t.selection.GetRange();if(o&&o.collapsed&&o.startContainer&&o.startContainer==o.endContainer){var e=t.phpParser.CheckParentSurrogate(o.startContainer);if(e){t.selection.SetInvisibleTextAfterNode(e);t.selection.SetInvisibleTextBeforeNode(e)}}}),10)}t.action.actions.quote.checkSpaceAfterQuotes(n);t.selection.SaveRange(false);setTimeout((function(){t.selection.SaveRange(false)}),10);t.On("OnIframeMouseDown",[i,n,s])}));BX.bind(s,"touchend",(function(){e.Focus()}));BX.bind(s,"touchstart",(function(){e.Focus()}));BX.bind(s,"click",(function(e){var i=e.target||e.srcElement;t.On("OnIframeClick",[e,i])}));BX.bind(s,"dblclick",(function(e){var i=e.target||e.srcElement;t.On("OnIframeDblClick",[e,i])}));BX.bind(s,"mouseup",(function(e){var i=e.target||e.srcElement;if(!t.synchro.IsSyncOn()){t.synchro.StartSync()}t.On("OnIframeMouseUp",[e,i])}));BX.bind(n,"click",(()=>this.copilot?.onIframeWindowClick()));BX.bind(o,"dragover",(function(){t.On("OnIframeDragOver",arguments)}));BX.bind(o,"dragenter",(function(){t.On("OnIframeDragEnter",arguments)}));BX.bind(o,"dragleave",(function(){t.On("OnIframeDragLeave",arguments)}));BX.bind(o,"dragexit",(function(){t.On("OnIframeDragExit",arguments)}));BX.bind(o,"drop",(function(){t.On("OnIframeDrop",arguments)}));if(BX.browser.IsFirefox()){BX.bind(o,"dragover",(function(e){e.preventDefault()}));BX.bind(o,"dragenter",(function(e){e.preventDefault()}))}BX.bind(o,"drop",BX.delegate(this.OnPasteHandler,this));BX.bind(o,"paste",(e=>{const t=new BX.Event.BaseEvent({data:{clipboardEvent:e}});BX.Event.EventEmitter.emitAsync(this.editor,"BXEditor:onBeforePasteAsync",t).then((()=>{if(!t.isDefaultPrevented()){this.OnPasteHandler(e)}}))}));BX.bind(o,"keyup",(function(i){var o=i.keyCode,n=t.selection.GetSelectedNode(true);e.SetFocusedFlag(true);if(o===t.KEY_CODES["space"]||o===t.KEY_CODES["enter"]){if(o===t.KEY_CODES["enter"]){e.OnEnterHandlerKeyUp(i,o,n)}t.On("OnIframeNewWord")}else{e.OnKeyUpArrowsHandler(i,o)}t.selection.SaveRange();t.On("OnIframeKeyup",[i,o,n]);if(o===t.KEY_CODES["backspace"]&&BX.browser.IsChrome()&&n&&n.nodeType=="3"&&n.nextSibling&&n.nextSibling.nodeType=="3"){e.editor.selection.ExecuteAndRestoreSimple((function(){e.editor.util.SetTextContent(n,e.editor.util.GetTextContent(n)+e.editor.util.GetTextContent(n.nextSibling));n.nextSibling.parentNode.removeChild(n.nextSibling)}))}if(!t.util.FirstLetterSupported()&&e.editor.parser.firstNodeCheck){e.editor.parser.FirstLetterCheckNodes("","",true)}if(BX.browser.IsChrome()){if(e.stopBugusScrollTimeout)clearTimeout(e.stopBugusScrollTimeout);e.stopBugusScrollTimeout=setTimeout((function(){e.stopBugusScroll=false}),200)}e.copilot?.onContentEditableKeyUp(i)}));BX.bind(this.document,"scroll",(()=>this.copilot?.onScrollHandler()));BX.bind(o,"mousedown",(function(i){var o=i.target||i.srcElement;if(!t.util.CheckImageSelectSupport()&&o.nodeName==="IMG"){t.selection.SelectNode(o)}if(!t.util.CheckPreCursorSupport()&&o.nodeName==="PRE"){var n=t.selection.GetSelectedNode(true);if(n&&n!=o){e.FocusPreElement(o,true)}}e.copilot?.onContentEditableMouseDown()}));BX.bind(o,"keydown",BX.proxy(this.KeyDown,this));if(BX.browser.IsChrome()){BX.bind(window,"scroll",BX.proxy((function(t){if(e.stopBugusScroll){if((!e.savedScroll||!e.savedScroll.scrollTop)&&e.lastSavedScroll)e.savedScroll=e.lastSavedScroll;if(e.savedScroll&&!e.lastSavedScroll)e.lastSavedScroll=e.savedScroll;e._RestoreScrollTop()}}),this))}var r={IMG:BX.message.SrcTitle+": ",A:BX.message.UrlTitle+": "};BX.bind(o,"mouseover",(function(e){var t=e.target||e.srcElement,i=t.getAttribute("href")||t.getAttribute("src"),o=t.nodeName;if(r[o]&&!t.hasAttribute("title")&&i&&i.indexOf("data:image/")===-1){t.setAttribute("title",r[o]+i);t.setAttribute("data-bx-clean-attribute","title")}}));this.editor.InitClipboardHandler()};o.prototype.KeyDown=function(e){var t=this,i=e.keyCode,o=this.editor.KEY_CODES;this.SetFocusedFlag(true);this.editor.iframeKeyDownPreventDefault=false;if(BX.browser.IsChrome()){this.stopBugusScroll=true;this.savedScroll=BX.GetWindowScrollPos(document)}var n=this.editor.SHORTCUTS[i],s=this.editor.selection.GetSelectedNode(true),r=this.editor.selection.GetRange(),a=this.document.body,l;if(e.key===" "&&this.copilot?.shouldBeShown()){this.copilot.show(true);e.preventDefault();return}this.copilot?.onContentEditableKeyDown();if((BX.browser.IsIE()||BX.browser.IsIE10()||BX.browser.IsIE11())&&!BX.util.in_array(i,[16,17,18,20,65,144,37,38,39,40])){if(s&&s.nodeName=="BODY"||r.startContainer&&r.startContainer.nodeName=="BODY"||r.startContainer==a.firstChild&&r.endContainer==a.lastChild&&r.startOffset==0&&r.endOffset==a.lastChild.length){BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandler,this))}}if((BX.browser.IsIE()||BX.browser.IsIE10()||BX.browser.IsIE11())&&i==o["backspace"]){BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandlerEx,this))}this.isUserTyping=true;if(this.typingTimeout){this.typingTimeout=clearTimeout(this.typingTimeout)}this.typingTimeout=setTimeout((function(){t.isUserTyping=false}),1e3);this.editor.synchro.StartSync(200);this.editor.On("OnIframeKeydown",[e,i,n,s]);if(this.editor.iframeKeyDownPreventDefault)return BX.PreventDefault(e);if((e.ctrlKey||e.metaKey)&&!e.altKey&&n){this.editor.action.Exec(n);return BX.PreventDefault(e)}if(i===o["backspace"]&&r.startOffset==0&&r.startContainer.nodeType==3&&r.startContainer.parentNode.firstChild==r.startContainer&&r.startContainer.parentNode&&r.startContainer.parentNode.nodeName=="BLOCKQUOTE"&&r.startContainer.parentNode.className){r.startContainer.parentNode.className=""}if(!BX.browser.IsSafari()&&(i===o["backspace"]||i===o["delete"])&&r.startContainer.nodeName==="#text"&&r.startContainer.previousSibling?.nodeName==="BLOCKQUOTE"&&r.startContainer.nextSibling?.nodeName!=="BR"&&r.startContainer.textContent.length===1){r.startContainer.before(BX.Tag.render`<span>&#XFEFF;</span>`.innerHTML)}if(i===o["delete"]&&r.collapsed&&r.endContainer.nodeType==3&&r.endOffset==r.endContainer.length){var d=this.editor.util.GetNextNotEmptySibling(r.endContainer);if(d){if(d.nodeName=="BR"){d=this.editor.util.GetNextNotEmptySibling(d)}if(d&&d.nodeName=="BLOCKQUOTE"&&d.className){d.className=""}}}if(s&&s.nodeName==="IMG"&&(i===o["backspace"]||i===o["delete"])){l=s.parentNode;l.removeChild(s);if(l.nodeName==="A"&&!l.firstChild){l.parentNode.removeChild(l)}setTimeout((function(){t.editor.util.Refresh(t.element)}),0);BX.PreventDefault(e)}if(r.collapsed&&this.OnKeyDownArrowsHandler(e,i,r)===false){return false}if((e.ctrlKey||e.metaKey)&&!e.altKey&&i===o["enter"]){if(this.IsFocused())this.editor.On("OnIframeBlur");this.editor.On("OnCtrlEnter",[e,this.editor.GetViewMode()]);return BX.PreventDefault(e)}if(BX.browser.IsFirefox()&&s&&(i===o["delete"]||i===o["backspace"])){var h=s.nodeName=="LI"?s:BX.findParent(s,{tag:"LI"},a);if(h&&h.firstChild&&h.firstChild.nodeName=="I"){var u=BX.findParent(h,{tag:"UL"},a);if(u){var c=this.editor.action.actions.insertUnorderedList.getCustomBullitClass(u);if(c){setTimeout((function(){if(u&&h&&h.innerHTML!==""){t.editor.action.actions.insertUnorderedList.checkCustomBullitList(u,c)}}),0)}}}}if(!this.editor.util.FirstLetterSupported()&&t.editor.parser.firstNodeCheck&&i===this.editor.KEY_CODES["backspace"]){t.editor.parser.FirstLetterBackspaceHandler(r)}if(!e.shiftKey&&(i===o["enter"]||i===o["backspace"])){return this.OnEnterHandler(e,i,s,r)}if(i===o["pageUp"]||i===o["pageDown"]){this.savedScroll=BX.GetWindowScrollPos(document);BX.addCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._RestoreScrollTop,this));setTimeout(BX.proxy(this._RestoreScrollTop,this),0)}};o.prototype._RestoreScrollTop=function(e){if(this.savedScroll){window.scrollTo(this.savedScroll.scrollLeft,this.savedScroll.scrollTop);this.savedScroll=null}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._RestoreScrollTop,this))};o.prototype._IEBodyClearHandler=function(e){var t=this.document.body.firstChild;if(e.keyCode==this.editor.KEY_CODES["enter"]&&t.nodeName=="P"&&t!=this.document.body.lastChild){if(t.innerHTML&&t.innerHTML.toLowerCase()=="<br>"){var i=t.nextSibling;this.editor.util.ReplaceWithOwnChildren(t);t=i}}if(t&&t.nodeName=="P"&&t==this.document.body.lastChild){this.editor.util.ReplaceWithOwnChildren(t)}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandler,this))};o.prototype._IEBodyClearHandlerEx=function(e){var t=this.document.body.firstChild;if(e.keyCode==this.editor.KEY_CODES["backspace"]&&t&&t.nodeName=="P"&&t==this.document.body.lastChild&&(this.editor.util.IsEmptyNode(t,true,true)||t.innerHTML&&t.innerHTML.toLowerCase()=="<br>")){this.editor.util.ReplaceWithOwnChildren(t)}BX.removeCustomEvent(this.editor,"OnIframeKeyup",BX.proxy(this._IEBodyClearHandlerEx,this))};o.prototype.OnEnterHandler=function(e,t,i,o){if(BX.browser.IsChrome()){this.document.body.style.minHeight=parseInt(this.document.body.style.minHeight)+1+"px";this.document.body.style.minHeight=parseInt(this.document.body.style.minHeight)-1+"px"}if(!i){return}var n=this;function s(e){if(e){if(e.nodeName!=="P"&&e.nodeName!=="DIV"){e=BX.findParent(e,(function(e){return e.nodeName==="P"||e.nodeName==="DIV"}),n.document.body)}var t=n.editor.util.GetInvisibleTextNode();if(e){e.parentNode.insertBefore(t,e);n.editor.util.ReplaceWithOwnChildren(e);n.editor.selection.SelectNode(t)}}}var r,a,l,d=["LI","P","H1","H2","H3","H4","H5","H6"],h=["UL","OL","MENU"];if(BX.util.in_array(i.nodeName,d)){l=i}else{l=BX.findParent(i,(function(e){return BX.util.in_array(e.nodeName,d)}),this.document.body)}if(l){if(l.nodeName==="LI"){if(t===n.editor.KEY_CODES["enter"]&&l&&l.parentNode){var u=n.editor.action.actions.insertUnorderedList.getCustomBullitClass(l.parentNode)}setTimeout((function(){var e=n.editor.selection.GetSelectedNode(true);if(e){r=BX.findParent(e,(function(e){return BX.util.in_array(e.nodeName,h)}),n.document.body);if(t===n.editor.KEY_CODES["enter"]&&l&&l.parentNode){n.editor.action.actions.insertUnorderedList.checkCustomBullitList(l.parentNode,u,true)}if(r&&BX.browser.IsChrome()&&t===n.editor.KEY_CODES["enter"]){var i,o=r.getElementsByTagName("LI");for(i=0;i<o.length;i++){o[i].innerHTML=o[i].innerHTML.replace(/\uFEFF/gi,"")}}if(!r){s(e)}}}),0)}else if(l.nodeName.match(/H[1-6]/)&&t===this.editor.KEY_CODES["enter"]){setTimeout((function(){s(n.editor.selection.GetSelectedNode())}),0)}return true}if(t===this.editor.KEY_CODES["enter"]&&!BX.browser.IsFirefox()&&this.editor.action.IsSupported("insertLineBreak")){if(BX.browser.IsIE10()||BX.browser.IsIE11()){this.editor.action.Exec("insertHTML","<br>"+this.editor.INVISIBLE_SPACE)}else if(BX.browser.IsChrome()){this.editor.action.Exec("insertLineBreak");if(BX.browser.IsMac()){var c="bx-editor-temp-"+Math.round(Math.random()*1e6);this.editor.action.Exec("insertHTML",'<span id="'+c+'">'+this.editor.INVISIBLE_SPACE+"</span>");var f=this.editor.GetIframeElement(c);if(f)BX.remove(f)}else{this.editor.action.Exec("insertHTML",this.editor.INVISIBLE_SPACE)}}else{this.editor.action.Exec("insertLineBreak")}return BX.PreventDefault(e)}if((BX.browser.IsChrome()||BX.browser.IsIE10()||BX.browser.IsIE11())&&t==this.editor.KEY_CODES["backspace"]&&o.collapsed){var p=BX.create("SPAN",false,this.document);this.editor.selection.InsertNode(p);var m=p.previousSibling;if(m&&m.nodeType==3&&this.editor.util.IsEmptyNode(m,false,false)){BX.remove(m)}this.editor.selection.SetBefore(p);BX.remove(p)}};o.prototype.OnEnterHandlerKeyUp=function(e,t,i){if(i){var o=this;if(!BX.util.in_array(i.nodeName,this.editor.GetBlockTags())){i=BX.findParent(i,(function(e){return BX.util.in_array(e.nodeName,o.editor.GetBlockTags())}),this.document.body)}if(i&&BX.util.in_array(i.nodeName,this.editor.GetBlockTags())){var n=BX.util.trim(i.innerHTML).toLowerCase();if(this.editor.util.IsEmptyNode(i,true,true)||n==""||n=="<br>"){i.removeAttribute("class")}}}};o.prototype.OnKeyDownArrowsHandler=function(e,t,i){var o,n,s,r,a=this.editor.KEY_CODES;this.keyDownRange=i;if(t===a["right"]||t===a["down"]){o=i.endContainer;s=o?o.nextSibling:false;n=o?o.parentNode:false;if(o.nodeType==3&&o.length==i.endOffset&&n&&n.nodeName!=="BODY"&&(!s||s&&s.nodeName=="BR"&&!s.nextSibling)&&(this.editor.util.IsBlockElement(n)||this.editor.util.IsBlockNode(n))){this.editor.selection.SetInvisibleTextAfterNode(n,true);return BX.PreventDefault(e)}else if(o.nodeType==3&&this.editor.util.IsEmptyNode(o)&&s&&(this.editor.util.IsBlockElement(s)||this.editor.util.IsBlockNode(s))){BX.remove(o);if(s.firstChild){this.editor.selection.SetBefore(s.firstChild)}else{this.editor.selection.SetAfter(s)}return BX.PreventDefault(e)}else if(o.nodeType==3&&o.length==i.endOffset&&n&&n.nodeName!=="BODY"&&s&&s.nodeName=="BR"&&!s.nextSibling&&(this.editor.util.IsBlockElement(n)||this.editor.util.IsBlockNode(n))){this.editor.selection.SetInvisibleTextAfterNode(n,true);return BX.PreventDefault(e)}}else if(t===a["left"]||t===a["up"]){o=i.startContainer;n=o?o.parentNode:false;r=o?o.previousSibling:false;if(o.nodeType==3&&i.endOffset===0&&n&&n.nodeName!=="BODY"&&!r&&(this.editor.util.IsBlockElement(n)||this.editor.util.IsBlockNode(n))){this.editor.selection.SetInvisibleTextBeforeNode(n);return BX.PreventDefault(e)}else if(o.nodeType==3&&this.editor.util.IsEmptyNode(o)&&r&&(this.editor.util.IsBlockElement(r)||this.editor.util.IsBlockNode(r))){BX.remove(o);if(r.lastChild){this.editor.selection.SetAfter(r.lastChild)}else{this.editor.selection.SetBefore(r)}return BX.PreventDefault(e)}}return true};o.prototype.OnKeyUpArrowsHandler=function(e,t){var i=this,o,n,s,r,a,l=this.editor.selection.GetRange(),d,h,u,c,f,p,m,b,v,g,B,y=this.editor.KEY_CODES;if(t===y["right"]||t===y["down"]){this.editor.selection.GetStructuralTags();if(l.collapsed){d=l.endContainer;f=this.editor.util.IsEmptyNode(d);m=this.editor.selection.CheckLastRange(l);u=d.nextSibling;if(!this.editor.util.CheckPreCursorSupport()){if(d.nodeName==="PRE"){o=d}else if(d.nodeType==3){o=BX.findParent(d,{tag:"PRE"},this.element)}if(o){if(this.keyDownRange){r=this.keyDownRange.endContainer;a=r==o?o:BX.findParent(r,(function(e){return e==o}),this.element)}i.FocusPreElement(o,false,a?null:"start")}}if(d.nodeType==3&&f&&u){d=u;f=this.editor.util.IsEmptyNode(d)}p=this.editor.util.CheckSurrogateNode(d);if(p){s=d.nextSibling;if(s&&s.nodeType==3&&this.editor.util.IsEmptyNode(s))this.editor.selection._MoveCursorAfterNode(s);else this.editor.selection._MoveCursorAfterNode(d);BX.PreventDefault(e)}else if(d.nodeType==1&&d.nodeName!="BODY"&&!f){if(m){this.editor.selection._MoveCursorAfterNode(d);BX.PreventDefault(e)}}else if(m&&d.nodeType==3&&!f){h=d.parentNode;if(h&&d===h.lastChild&&h.nodeName!="BODY"){this.editor.selection._MoveCursorAfterNode(h)}}else if(d.nodeType==3&&d.parentNode){h=d.parentNode;c=h.previousSibling;if((this.editor.util.IsBlockElement(h)||this.editor.util.IsBlockNode(h))&&c&&c.nodeType==3&&this.editor.util.IsEmptyNode(c)){BX.remove(c)}}}else{b=l.startContainer;v=l.endContainer;g=this.editor.util.CheckSurrogateNode(b);B=this.editor.util.CheckSurrogateNode(v);if(g){n=b.previousSibling;if(n&&n.nodeType==3&&this.editor.util.IsEmptyNode(n))l.setStartBefore(n);else l.setStartBefore(b);this.editor.selection.SetSelection(l)}if(B){s=v.nextSibling;if(s&&s.nodeType==3&&this.editor.util.IsEmptyNode(s))l.setEndAfter(s);else l.setEndAfter(v);this.editor.selection.SetSelection(l)}}}else if(t===y["left"]||t===y["up"]){this.editor.selection.GetStructuralTags();if(l.collapsed){d=l.startContainer;f=this.editor.util.IsEmptyNode(d);m=this.editor.selection.CheckLastRange(l);if(d.nodeType==3&&f&&d.previousSibling){d=d.previousSibling;f=this.editor.util.IsEmptyNode(d)}if(!this.editor.util.CheckPreCursorSupport()){if(d.nodeName==="PRE"){o=d}else if(d.nodeType==3){o=BX.findParent(d,{tag:"PRE"},this.element)}if(o){if(this.keyDownRange){r=this.keyDownRange.startContainer;a=r==o?o:BX.findParent(r,(function(e){return e==o}),this.element)}i.FocusPreElement(o,false,a?null:"end")}}p=this.editor.util.CheckSurrogateNode(d);if(p){n=d.previousSibling;if(n&&n.nodeType==3&&this.editor.util.IsEmptyNode(n))this.editor.selection._MoveCursorBeforeNode(n);else this.editor.selection._MoveCursorBeforeNode(d);BX.PreventDefault(e)}else if(d.nodeType==1&&d.nodeName!="BODY"&&!f){if(m){this.editor.selection._MoveCursorBeforeNode(d);BX.PreventDefault(e)}}else if(m&&d.nodeType==3&&!f){h=d.parentNode;if(h&&d===h.firstChild&&h.nodeName!="BODY"){this.editor.selection._MoveCursorBeforeNode(h)}}else if(d.nodeType==3&&d.parentNode){h=d.parentNode;c=h.nextSibling;if((this.editor.util.IsBlockElement(h)||this.editor.util.IsBlockNode(h))&&c&&c.nodeType==3&&this.editor.util.IsEmptyNode(c)){BX.remove(c)}}}else{b=l.startContainer;v=l.endContainer;g=this.editor.util.CheckSurrogateNode(b);B=this.editor.util.CheckSurrogateNode(v);if(g){n=b.previousSibling;if(n&&n.nodeType==3&&this.editor.util.IsEmptyNode(n))l.setStartBefore(n);else l.setStartBefore(b);this.editor.selection.SetSelection(l)}if(B){s=v.nextSibling;if(s&&s.nodeType==3&&this.editor.util.IsEmptyNode(s))l.setEndAfter(s);else l.setEndAfter(v);this.SetSelection(l)}}}this.keyDownRange=null};o.prototype.FocusPreElement=function(e,t,i){var o=this;if(this._focusPreElementTimeout)this._focusPreElementTimeout=clearTimeout(this._focusPreElementTimeout);if(t){this._focusPreElementTimeout=setTimeout((function(){o.FocusPreElement(e,false,i)}),100);return}BX.focus(e);if(i=="end"&&e.lastChild){this.editor.selection.SetAfter(e.lastChild)}else if(i=="start"&&e.firstChild){this.editor.selection.SetBefore(e.firstChild)}};o.prototype.OnPasteHandler=function(e){if(!this.editor.skipPasteHandler){this.editor.skipPasteHandler=true;this.editor.pasteNodeIndex={};var t=document.documentElement.scrollTop||document.body.scrollTop,i=document.documentElement.scrollLeft||document.body.scrollLeft,o=this,n=[],s,r,a,l;function d(e){if(e&&e.setAttribute){var t=Math.round(Math.random()*1e6);o.editor.pasteNodeIndex[t]=true;e.setAttribute("data-bx-paste-flag",t)}}s=this.document.body;if(s){l=s.querySelectorAll("*");for(r=0;r<l.length;r++){if(l[r].nodeType==1&&l[r].nodeName!="BODY"&&l[r].nodeName!="HEAD"){n.push(l[r])}}for(r=0;r<s.parentNode.childNodes.length;r++){a=s.parentNode.childNodes[r];if(a.nodeType==1&&a.nodeName!="BODY"&&a.nodeName!="HEAD"){n.push(a)}}}for(r=0;r<n.length;r++){d(n[r])}var h=this.editor.synchro.IsSyncOn();if(h){this.editor.synchro.StopSync()}if(this.editor.iframeView.pasteHandlerTimeout){clearTimeout(this.editor.iframeView.pasteHandlerTimeout)}this.pasteHandlerTimeout=setTimeout((function(){o.editor.SetCursorNode();o.editor.pasteHandleMode=true;o.editor.bbParseContentMode=true;o.editor.synchro.lastIframeValue=false;if(!o.editor.skipPasteControl){o.editor.pasteControl.SaveIframeContent(o.GetValue());o.editor.pasteControl.CheckAndShow()}o.editor.synchro.FromIframeToTextarea(true,true);o.editor.pasteHandleMode=false;o.editor.bbParseContentMode=false;o.editor.synchro.lastTextareaValue=false;o.editor.synchro.FromTextareaToIframe(true);o.editor.RestoreCursor();o.editor.On("OnIframePaste");o.editor.On("OnIframeNewWord");o.editor.skipPasteHandler=false;if(h){o.editor.synchro.StartSync()}if(window.scrollTo){window.scrollTo(i,t)}}),0)}};o.prototype.InitAutoLinking=function(){var e=this,t=this.editor,i=t.action.IsSupportedByBrowser("autoUrlDetect"),o=BX.browser.IsIE()||BX.browser.IsIE9()||BX.browser.IsIE10();if(i)t.action.Exec("autoUrlDetect",false);if(t.config.autoLink===false)return;var n={CODE:1,PRE:1,A:1,SCRIPT:1,HEAD:1,TITLE:1,STYLE:1},s=/(((?:https?|ftp):\/\/|www\.)[^\s'"<]{3,500})/gi,r=/[\.a-z0-9_\-]+@[\.a-z0-9_\-]+\.[\.a-z0-9_\-]+/gi,a=100,l={")":"(","]":"[","}":"{"};this.editor.autolinkUrlRegExp=s;this.editor.autolinkEmailRegExp=r;function d(){try{if(h()){t.selection.ExecuteAndRestore((function(e,t){if(t&&t.parentNode)u(t.parentNode)}))}}catch(e){}}function h(){var e,i,o=false,n=t.GetIframeDoc(),a=n.createTreeWalker(n.body,NodeFilter.SHOW_TEXT,null,false);while(e=a.nextNode()){i=e.nodeValue||"";if((i.match(r)||i.match(s))&&e.parentNode&&e.parentNode.nodeName!="A"){o=true;break}}return o}function u(e){if(e&&!n[e.nodeName]){var t=BX.findParent(e,(function(e){return!!n[e.nodeName]}),e.ownerDocument.body);if(t)return e;if(e===e.ownerDocument.documentElement)e=e.ownerDocument.body;return m(e)}}function c(t){t=BX.util.htmlspecialchars(t);return t.replace(s,(function(t,i){var o=(i.match(/([^\w\u0430-\u0456\u0451\/\-#](,?))$/i)||[])[1]||"",n=l[o];i=i.replace(/([^\w\u0430-\u0456\u0451\/\-#](,?))$/i,"");if(i.split(n).length>i.split(o).length){i=i+o;o=""}var s=i,r=BX.util.htmlspecialchars(i);if(i.length>a)r=r.substr(0,a)+"...";if(s.substr(0,4)==="www.")s="http://"+s;BX.onCustomEvent(e.editor,"OnAfterUrlConvert",[s]);return'<a href="'+s+'">'+r+"</a>"+o}))}function f(e){e=BX.util.htmlspecialchars(e);return e.replace(r,(function(e){var t=(e.match(/([^\w\/\-](,?))$/i)||[])[1]||"",i=l[t];e=e.replace(/([^\w\/\-](,?))$/i,"");if(e.split(i).length>e.split(t).length){e=e+t;t=""}var o="mailto:"+e;return'<a href="'+o+'">'+e+"</a>"+t}))}function p(e){var t=e._bx_autolink_temp_div;if(!t)t=e._bx_autolink_temp_div=e.createElement("div");return t}function m(e){var t,i,o;if(e&&!n[e.nodeName]){if(e.nodeType===3&&e.data.match(s)&&e.parentNode){i=e.parentNode;o=p(i.ownerDocument);o.innerHTML="<span></span>"+c(e.data);o.removeChild(o.firstChild);while(o.firstChild)i.insertBefore(o.firstChild,e);i.removeChild(e)}else if(e.nodeType===3&&e.data.match(r)&&e.parentNode){i=e.parentNode;o=p(i.ownerDocument);o.innerHTML="<span></span>"+f(e.data);o.removeChild(o.firstChild);while(o.firstChild)i.insertBefore(o.firstChild,e);i.removeChild(e)}else if(e.nodeType===1){var a=e.childNodes,l;for(l=0;l<a.length;l++)m(a[l]);t=e}}return t}if(!o||o&&i){BX.addCustomEvent(t,"OnIframeNewWord",(function(){if(t.autolinkTimeout)t.autolinkTimeout=clearTimeout(t.autolinkTimeout);t.autolinkTimeout=setTimeout(d,500)}));BX.addCustomEvent(t,"OnSubmit",(function(){try{u(t.GetIframeDoc().body)}catch(e){}}))}var b=t.sandbox.GetDocument().getElementsByTagName("a"),v=function(e){var i=BX.util.trim(t.util.GetTextContent(e));if(i.substr(0,4)==="www.")i="http://"+i;return i};BX.addCustomEvent(t,"OnIframeKeydown",(function(e,t,i,o){if(b.length>0&&o){var n=BX.findParent(o,{tag:"A"},o.ownerDocument.body);if(n){var r=v(n);setTimeout((function(){var e=v(n);if(e===r)return;if(e.match(s))n.setAttribute("href",e)}),0)}}}))};o.prototype.IsUserTypingNow=function(e){return this.isFocused&&this.isShown&&this.isUserTyping};o.prototype.CheckContentLastChild=function(e){if(!e){e=this.element}var t=e.lastChild;if(t&&(this.editor.util.IsEmptyNode(t,true)&&this.editor.util.IsBlockNode(t.previousSibling)||this.editor.phpParser.IsSurrogate(t))){e.appendChild(BX.create("BR",{},e.ownerDocument));e.appendChild(this.editor.util.GetInvisibleTextNode())}};function s(e,t,i){this.INTERVAL=500;this.editor=e;this.textareaView=t;this.iframeView=i;this.lastFocused="wysiwyg";this.InitEventHandlers()}s.prototype={FromIframeToTextarea:function(e,t){var i;if(this.editor.bbCode){i=this.iframeView.GetValue(this.editor.bbParseContentMode,false);i=BX.util.trim(i);if(i!==this.lastIframeValue){var o=this.editor.bbParser.Unparse(i);this.textareaView.SetValue(o,false,t||this.editor.bbParseContentMode);if(typeof this.lastSavedIframeValue!=="undefined"&&this.lastSavedIframeValue!=i){this.editor.On("OnContentChanged",[o,i])}this.lastSavedIframeValue=i;this.lastIframeValue=i}}else{i=this.iframeView.GetValue();i=BX.util.trim(i);if(i!==this.lastIframeValue){this.textareaView.SetValue(i,true,t);if(typeof this.lastSavedIframeValue!=="undefined"&&this.lastSavedIframeValue!=i){this.editor.On("OnContentChanged",[this.textareaView.GetValue()||"",i||""])}this.lastSavedIframeValue=i;this.lastIframeValue=i}}},FromTextareaToIframe:function(e){var t=this.textareaView.GetValue();if(t!==this.lastTextareaValue){if(t){if(this.editor.bbCode){var i=this.editor.bbParser.Parse(t);i=i.replace(/\u2060/gi,'<span id="bx-cursor-node"> </span>');this.iframeView.SetValue(i,e)}else{t=t.replace(/\u2060/gi,'<span id="bx-cursor-node"> </span>');this.iframeView.SetValue(t,e)}}else{this.iframeView.Clear()}this.lastTextareaValue=t;this.editor.On("OnContentChanged",[t||"",this.iframeView.GetValue()||""])}},FullSyncFromIframe:function(){this.lastIframeValue=false;this.FromIframeToTextarea(true,true);this.lastTextareaValue=false;this.FromTextareaToIframe(true)},Sync:function(){var e=true;var t=this.editor.currentViewName;if(t==="split"){if(this.GetSplitMode()==="code"){this.FromTextareaToIframe(e)}else{this.FromIframeToTextarea(e)}}else if(t==="code"){this.FromTextareaToIframe(e)}else{this.FromIframeToTextarea(e)}},GetSplitMode:function(){var e=false;if(this.editor.currentViewName=="split"){if(this.editor.iframeView.IsFocused()){e="wysiwyg"}else if(this.editor.textareaView.IsFocused()){e="code"}else{e=this.lastFocused}}return e},InitEventHandlers:function(){var e=this;BX.addCustomEvent(this.editor,"OnTextareaFocus",(function(){e.lastFocused="code";e.StartSync()}));BX.addCustomEvent(this.editor,"OnIframeFocus",(function(){e.lastFocused="wysiwyg";e.StartSync()}));BX.addCustomEvent(this.editor,"OnTextareaBlur",BX.delegate(this.StopSync,this));BX.addCustomEvent(this.editor,"OnIframeBlur",BX.delegate(this.StopSync,this))},StartSync:function(e){var t=this;if(this.interval){this.interval=clearTimeout(this.interval)}this.delay=e||this.INTERVAL;function i(){t.delay=t.INTERVAL;t.Sync();t.interval=setTimeout(i,t.delay)}this.interval=setTimeout(i,t.delay)},StopSync:function(){if(this.interval){this.interval=clearTimeout(this.interval)}},IsSyncOn:function(){return!!this.interval},OnIframeMousedown:function(e,t,i){},IsFocusedOnTextarea:function(){return this.editor.currentViewName==="code"||this.editor.currentViewName==="split"&&this.GetSplitMode()==="code"}};window.BXEditorTextareaView=t;window.BXEditorIframeView=o;window.BXEditorViewsSynchro=s})();
//# sourceMappingURL=html-views.map.js