Your IP : 18.119.19.206


Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/node/
Upload File :
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/node/text.min.js

(function(){"use strict";BX.namespace("BX.Landing");const e=BX.Landing.Utils.escapeText;const t=BX.Landing.Utils.Matchers.headerTag;const n=BX.Landing.Utils.changeTagName;const i=BX.Landing.Utils.textToPlaceholders;BX.Landing.Block.Node.Text=function(e){BX.Runtime.loadExtension("landing.node.text.tableeditor");BX.Landing.Block.Node.apply(this,arguments);this.type="text";this.tableBaseFontSize="22";this.onClick=this.onClick.bind(this);this.onPaste=this.onPaste.bind(this);this.onDrop=this.onDrop.bind(this);this.onInput=this.onInput.bind(this);this.onKeyDown=this.onKeyDown.bind(this);this.onMousedown=this.onMousedown.bind(this);this.onMouseup=this.onMouseup.bind(this);this.node.addEventListener("mousedown",this.onMousedown);this.node.addEventListener("click",this.onClick);this.node.addEventListener("paste",this.onPaste);this.node.addEventListener("drop",this.onDrop);this.node.addEventListener("input",this.onInput);this.node.addEventListener("keydown",this.onKeyDown);document.addEventListener("mouseup",this.onMouseup)};BX.Landing.Block.Node.Text.currentNode=null;BX.Landing.Block.Node.Text.prototype={__proto__:BX.Landing.Block.Node.prototype,superClass:BX.Landing.Block.Node.prototype,constructor:BX.Landing.Block.Node.Text,onAllowInlineEdit:function(){this.node.setAttribute("title",e(BX.Landing.Loc.getMessage("LANDING_TITLE_OF_TEXT_NODE")))},onChange:function(e,t){this.superClass.onChange.call(this,t);if(!e){BX.Landing.UI.Panel.EditorPanel.getInstance().adjustPosition(this.node)}if(!t){BX.Landing.History.getInstance().push()}},onKeyDown:function(e){if(e.code==="Backspace"){this.onBackspaceDown(e)}this.onInput(e)},onInput:function(e){clearTimeout(this.inputTimeout);const t=e.keyCode||e.which;if(!(t===90&&(top.window.navigator.userAgent.match(/win/i)?e.ctrlKey:e.metaKey))){this.inputTimeout=setTimeout(function(){if(this.lastValue!==this.getValue()){this.onChange(true);this.lastValue=this.getValue()}}.bind(this),400)}if(this.isTable(e)){const t=parseInt(window.getComputedStyle(e.srcElement).getPropertyValue("font-size"));if(e.srcElement.textContent===""&&BX.Dom.hasClass(e.srcElement,"landing-table-td")&&t<this.tableBaseFontSize){BX.Dom.addClass(e.srcElement,"landing-table-td-height")}else{BX.Dom.removeClass(e.srcElement,"landing-table-td-height")}}},onEscapePress:function(){if(this.isEditable()){if(this===BX.Landing.Block.Node.Text.currentNode){BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}this.disableEdit()}},onDrop:function(e){e.preventDefault()},onPaste:function(e){e.preventDefault();if(e.clipboardData&&e.clipboardData.getData){const t=e.clipboardData.getData("text/plain");let n=BX.Text.encode(t);if(this.isLinkPasted(t)){n=this.prepareToLink(n)}const i=n.replace(new RegExp("\n","g"),"<br>");document.execCommand("insertHTML",false,i)}else{const e=window.clipboardData.getData("text");document.execCommand("paste",true,BX.Text.encode(e))}this.onChange()},onDocumentClick:function(e){if(this.isEditable()&&!this.fromNode){BX.Landing.UI.Panel.EditorPanel.getInstance().hide();this.disableEdit()}this.fromNode=false},onMousedown:function(e){if(!this.manifest.group){this.fromNode=true;if(this.manifest.allowInlineEdit!==false&&BX.Landing.Main.getInstance().isControlsEnabled()){e.stopPropagation();this.enableEdit();if(this.isTable(e)){this.disableEdit();BX.Landing.Block.Node.Text.currentNode.node.querySelectorAll(".landing-table-container").forEach((function(e){if(!e.hasAttribute("table-prepare")){BX.Landing.Block.Node.Text.prototype.prepareNewTable(e)}}));const t=parseInt(window.getComputedStyle(e.srcElement).getPropertyValue("font-size"));if(e.srcElement.textContent===""&&BX.Dom.hasClass(e.srcElement,"landing-table-td")&&t<this.tableBaseFontSize){BX.Dom.addClass(e.srcElement,"landing-table-td-height")}else{BX.Dom.removeClass(e.srcElement,"landing-table-td-height")}}else{if(!this.manifest.textOnly&&!BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){BX.Landing.UI.Panel.EditorPanel.getInstance().show(this.node,null,this.buttons)}if(BX.Landing.Block.Node.Text.nodeTableContainerList){BX.Landing.Block.Node.Text.nodeTableContainerList.forEach((function(e){e.tableEditor.unselect(e.tableEditor)}))}}BX.Landing.UI.Tool.ColorPicker.hideAll()}requestAnimationFrame((function(){if(e.target.nodeName==="A"||e.target.parentElement.nodeName==="A"){const t=document.createRange();t.selectNode(e.target);window.getSelection().removeAllRanges();window.getSelection().addRange(t)}}))}},onMouseup:function(){setTimeout(function(){this.fromNode=false}.bind(this),10)},onClick:function(e){if(this.isTable(e)){this.addTableButtons(e)}e.stopPropagation();e.preventDefault();this.fromNode=false;if(e.target.nodeName==="A"||e.target.parentElement.nodeName==="A"){const t=document.createRange();t.selectNode(e.target);window.getSelection().removeAllRanges();window.getSelection().addRange(t)}},isEditable:function(){return this.node.isContentEditable},enableEdit:function(){const e=BX.Landing.Block.Node.Text.currentNode;if(e){const e=BX.Landing.Block.Node.Text.currentNode.node;const t=e.querySelectorAll(".landing-table-container");if(t.length>0){t.forEach((function(e){if(!e.tableEditor){e.tableEditor=new BX.Landing.Node.Text.TableEditor.default(e)}}));BX.Landing.Block.Node.Text.nodeTableContainerList=t}}if(!this.isEditable()&&!BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){if(this!==BX.Landing.Block.Node.Text.currentNode&&BX.Landing.Block.Node.Text.currentNode!==null){BX.Landing.Block.Node.Text.currentNode.disableEdit()}BX.Landing.Block.Node.Text.currentNode=this;this.buttons=[];this.buttons.push(this.getDesignButton());if(BX.Landing.Main.getInstance()["options"]["allow_ai_text"]){this.buttons.push(this.getAiTextButton())}if(this.isHeader()){this.buttons.push(this.getChangeTagButton());this.getChangeTagButton().onChangeHandler=this.onChangeTag.bind(this)}this.lastValue=this.getValue();this.node.contentEditable=true;this.node.setAttribute("title","")}},getDesignButton:function(){if(!this.designButton){this.designButton=new BX.Landing.UI.Button.Design("design",{html:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_DESIGN"),attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_DESIGN")},onClick:function(){BX.Landing.UI.Panel.EditorPanel.getInstance().hide();this.disableEdit();this.onDesignShow(this.manifest.code)}.bind(this)})}return this.designButton},getAiTextButton:function(){if(!this.aiTextButton){this.aiTextButton=new BX.Landing.UI.Button.AiText.getInstance("ai_text",{html:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_AI_TEXT"),attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_AI_TEXT")},sections:this.manifest.sections,onSelect:function(e){this.node.innerHTML=e.data.replace(/(\r\n|\r|\n)/g,"<br>");this.onChange()}.bind(this)})}return this.aiTextButton},disableEdit:function(){if(this.isEditable()){this.node.contentEditable=false;if(this.lastValue!==this.getValue()){this.onChange();this.lastValue=this.getValue()}if(this.isAllowInlineEdit()){this.node.setAttribute("title",e(BX.Landing.Loc.getMessage("LANDING_TITLE_OF_TEXT_NODE")))}}},getField:function(){if(!this.field){this.field=new BX.Landing.UI.Field.Text({selector:this.selector,title:this.manifest.name,content:this.node.innerHTML,textOnly:this.manifest.textOnly,bind:this.node});if(this.isHeader()){this.field.changeTagButton=this.getChangeTagButton()}}else{this.field.setValue(this.node.innerHTML);this.field.content=this.node.innerHTML}return this.field},setValue:function(e,t,n){this.preventSave(t);this.lastValue=this.isSavePrevented()?this.getValue():this.lastValue;this.node.innerHTML=e;this.onChange(false,n)},getValue:function(){if(this.node.querySelector(".landing-table-container")!==null){const e=this.node.cloneNode(true);this.prepareTable(e);return i(e.innerHTML)}return i(this.node.innerHTML)},isHeader:function(){return t.test(this.node.nodeName)},isTable:function(e){let t=false;if(BX.Landing.Block.Node.Text.currentNode&&e){BX.Landing.Block.Node.Text.currentNode.node.querySelectorAll(".landing-table-container").forEach((function(n){if(n.contains(e.srcElement)){t=true}}))}return t},prepareNewTable:function(e){e.querySelectorAll("br").forEach((function(e){e.remove()}));e.setAttribute("table-prepare","true");BX.Landing.Block.Node.Text.currentNode.onChange(true)},addTableButtons:function(e){const t=[];let n=[];let i=[];const s=this.getTableButtons();const a=[s[0],s[1],s[2],s[3]];const o=BX.Landing.Block.Node.Text.currentNode.node;let l=null;let d=false;let r=false;let c=false;let h=true;if(BX.Dom.hasClass(e.srcElement,"landing-table")||BX.Dom.hasClass(e.srcElement,"landing-table-col-dnd")){h=false}if(BX.Dom.hasClass(e.srcElement,"landing-table-row-add")){r=true}if(BX.Dom.hasClass(e.srcElement,"landing-table-col-add")){c=true}let g=[];const u=o.querySelectorAll(".landing-table");if(u.length>0){u.forEach((function(t){if(t.contains(e.srcElement)){l=t;return true}}))}let f;s.forEach((function(t){t["options"]["srcElement"]=e.srcElement;t["options"]["node"]=o;t["options"]["table"]=l}));if(BX.Dom.hasClass(e.srcElement,"landing-table-row-dnd")){i=e.srcElement.parentNode.children;i=Array.from(i);if(this.getAmountTableRows(l)>1){n=[0,1,2,3,4,5,6]}else{n=[0,1,2,3,4,5]}n.forEach((function(e){s[e]["options"]["target"]="row";s[e]["options"]["setTd"]=i;t.push(s[e])}))}if(BX.Dom.hasClass(e.srcElement.parentNode,"landing-table-col-dnd")){const a=e.srcElement.parentElement.parentElement.childNodes;const o=Array.from(a);const d=[];o.forEach((function(e){if(e.nodeType===1){d.push(e)}}));const r=d.indexOf(e.srcElement.parentElement);const c=e.srcElement.parentElement.parentElement.parentElement.childNodes;c.forEach((function(e){if(e.nodeType===1){const t=[];e.childNodes.forEach((function(e){if(e.nodeType===1){t.push(e)}}));if(t[r]){i.push(t[r])}}}));if(this.getAmountTableCols(l)>1){n=[0,1,2,3,4,5,7]}else{n=[0,1,2,3,4,5]}n.forEach((function(e){s[e]["options"]["target"]="col";s[e]["options"]["setTd"]=i;t.push(s[e])}))}if(BX.Dom.hasClass(e.srcElement,"landing-table-th-select-all")){if(BX.Dom.hasClass(e.srcElement,"landing-table-th-select-all-selected")){f=true;const a=e.srcElement.parentElement.parentElement.childNodes;a.forEach((function(e){e.childNodes.forEach((function(e){i.push(e)}))}));n=[0,1,2,3,4,5,8,9,10];n.forEach((function(e){s[e]["options"]["target"]="table";s[e]["options"]["setTd"]=i;t.push(s[e])}))}else{f=false;BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}}if(BX.Dom.hasClass(e.srcElement,"landing-table-td")||e.srcElement.closest(".landing-table-td")!==null){i.push(e.srcElement);n=[3,2,1,0];n.forEach((function(e){s[e]["options"]["target"]="cell";s[e]["options"]["setTd"]=i;s[e].insertAfter="strikeThrough";t.push(s[e])}));d=true;g=["justifyLeft","justifyCenter","justifyRight","justifyFull","createTable","pasteTable"]}let T;const L=[];i.forEach((function(e){if(e.nodeType===1){T=undefined;if(BX.Dom.hasClass(e,"text-left")){T="alignLeft"}if(BX.Dom.hasClass(e,"text-center")){T="alignCenter"}if(BX.Dom.hasClass(e,"text-right")){T="alignRight"}if(BX.Dom.hasClass(e,"text-justify")){T="alignJustify"}L.push(T)}}));let E=0;let B=true;while(E<L.length&&B){if(E>0){if(L[E]!==L[E-1]){B=false}}E++}if(B){T=L[0]}else{T=undefined}if(T){a.forEach((function(e){if(e.id===T){BX.Dom.addClass(e.layout,"landing-ui-active")}}))}if(t[0]&&t[1]&&t[2]&&t[3]){t[0]["options"]["alignButtons"]=a;t[1]["options"]["alignButtons"]=a;t[2]["options"]["alignButtons"]=a;t[3]["options"]["alignButtons"]=a}if(!this.manifest.textOnly){if(h){if(!r&&!c&&l){if(!d){if(f===false){BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}else{BX.Landing.UI.Panel.EditorPanel.getInstance().show(l.parentNode,null,t,true)}}else{BX.Landing.UI.Panel.EditorPanel.getInstance().show(l.parentNode,null,t,true,g)}}}else{BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}}},getChangeTagButton:function(){if(!this.changeTagButton){this.changeTagButton=new BX.Landing.UI.Button.ChangeTag("changeTag",{html:'<span class="landing-ui-icon-editor-'+this.node.nodeName.toLowerCase()+'"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_CHANGE_TAG")},onChange:this.onChangeTag.bind(this)})}this.changeTagButton.insertAfter="unlink";this.changeTagButton.activateItem(this.node.nodeName);return this.changeTagButton},getTableButtons:function(){this.buttons=[];this.buttons.push(new BX.Landing.UI.Button.AlignTable("alignLeft",{html:'<span class="landing-ui-icon-editor-left"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_LEFT")}}),new BX.Landing.UI.Button.AlignTable("alignCenter",{html:'<span class="landing-ui-icon-editor-center"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_CENTER")}}),new BX.Landing.UI.Button.AlignTable("alignRight",{html:'<span class="landing-ui-icon-editor-right"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_RIGHT")}}),new BX.Landing.UI.Button.AlignTable("alignJustify",{html:'<span class="landing-ui-icon-editor-justify"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_ALIGN_JUSTIFY")}}),new BX.Landing.UI.Button.TableColorAction("tableTextColor",{text:BX.Landing.Loc.getMessage("EDITOR_ACTION_SET_FORE_COLOR"),attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_COLOR")}}),new BX.Landing.UI.Button.TableColorAction("tableBgColor",{html:'<i class="landing-ui-icon-editor-fill-color"></i>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_TABLE_CELL_BG")}}),new BX.Landing.UI.Button.DeleteElementTable("deleteRow",{html:'<span class="landing-ui-icon-editor-delete"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_DELETE_ROW_TABLE")}}),new BX.Landing.UI.Button.DeleteElementTable("deleteCol",{html:'<span class="landing-ui-icon-editor-delete"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_DELETE_COL_TABLE")}}),new BX.Landing.UI.Button.StyleTable("styleTable",{html:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_TABLE_STYLE")+'<i class="fas fa-chevron-down g-ml-8"></i>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_TABLE_STYLE")}}),new BX.Landing.UI.Button.CopyTable("copyTable",{text:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_TABLE_COPY"),attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_TABLE_COPY")}}),new BX.Landing.UI.Button.DeleteTable("deleteTable",{html:'<span class="landing-ui-icon-editor-delete"></span>',attrs:{title:BX.Landing.Loc.getMessage("LANDING_TITLE_OF_EDITOR_ACTION_TABLE_DELETE")}}));return this.buttons},onChangeTag:function(e,t){this.node=n(this.node,e);this.node.addEventListener("mousedown",this.onMousedown);this.node.addEventListener("click",this.onClick);this.node.addEventListener("paste",this.onPaste);this.node.addEventListener("drop",this.onDrop);this.node.addEventListener("input",this.onInput);this.node.addEventListener("keydown",this.onInput);if(!this.getField().isEditable()&&!t){this.disableEdit();this.enableEdit()}const i={};i[this.selector]=e;if(!t){this.changeOptionsHandler(i).then((()=>{BX.Landing.History.getInstance().push()}))}},getAmountTableCols:function(e){return e.querySelectorAll(".landing-table-col-dnd").length},getAmountTableRows:function(e){return e.querySelectorAll(".landing-table-row-dnd").length},prepareTable:function(e){const t=["table-selected-all","landing-table-th-select-all-selected","landing-table-cell-selected","landing-table-row-selected","landing-table-th-selected","landing-table-th-selected-cell","landing-table-th-selected-top","landing-table-th-selected-x","landing-table-tr-selected-left","landing-table-tr-selected-y","landing-table-col-selected","landing-table-tr-selected","table-selected-all-right","table-selected-all-bottom"];t.forEach((function(t){e.querySelectorAll("."+t).forEach((function(e){BX.Dom.removeClass(e,t)}))}));return e},onBackspaceDown:function(e){const t=window.getSelection();const n=t.getRangeAt(0).startOffset;if(n===0){let n=t.focusNode;if(!BX.Type.isNil(n)&&n.nodeType!==3){if(n.firstChild.nodeType===3&&n.firstChild.firstChild.nodeType===3){n=n.firstChild.firstChild}else if(n.firstChild.nodeType!==3){n=n.firstChild}else{n=null}}if(n){const t=n.parentNode;const i=["BLOCKQUOTE","UL"];if(t&&i.includes(t.nodeName)){const e=document.createElement("div");e.append(n);t.append(e)}let s=n.parentNode.parentNode;while(s&&!i.includes(s.nodeName)){s=s.parentNode}if(s&&s.childNodes.length===1){s.after(n.parentNode);s.remove();e.preventDefault()}}}},isLinkPasted:function(e){const t=/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/;return!!e.match(t)},prepareToLink:function(e){return"<a class='g-bg-transparent' href='"+e+"' target='_blank'> "+e+" </a>"}}})();
//# sourceMappingURL=text.map.js