/* * This file is part of the TYPO3 CMS project. * * It is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, either version 2 * of the License, or any later version. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. * * The TYPO3 project - inspiring people to share! */ import B from"@typo3/core/document-service.js";import{SeverityEnum as q}from"@typo3/backend/enum/severity.js";import"bootstrap";import A from"@typo3/backend/modal.js";import G from"@typo3/core/security-utility.js";import{property as w,customElement as z}from"lit/decorators.js";import{LitElement as F,html as l,nothing as p}from"lit";import{classMap as O}from"lit/directives/class-map.js";import{styleMap as P}from"lit/directives/style-map.js";import{createRef as U,ref as L}from"lit/directives/ref.js";import{CodeMirrorElement as j}from"@typo3/backend/code-editor/element/code-mirror-element.js";import o from"~labels/core.wizards";import I from"~labels/core.common";import W from"~labels/backend.alt_doc";var f=function(d,e,t,i){var r=arguments.length,n=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,t,i);else for(var a=d.length-1;a>=0;a--)(s=d[a])&&(n=(r<3?s(n):r>3?s(e,t,n):s(e,t))||n);return r>3&&n&&Object.defineProperty(e,t,n),n},c,m;(function(d){d.none="",d.slide="slide",d.collect="collect",d.collectReverse="collectReverse"})(m||(m={}));let u=c=class extends F{constructor(){super(...arguments),this.colCount=1,this.rowCount=1,this.readOnly=!1,this.fieldName="",this.data=[],this.codeMirrorConfig={},this.previewAreaRef=U(),this.codeMirrorRef=U(),this.defaultCell={spanned:0,rowspan:1,colspan:1,name:"",colpos:"",column:void 0,identifier:"",slideMode:m.none},this.modalButtonClickHandler=e=>{const t=e.target,i=e.currentTarget;t.name==="cancel"?i.hideModal():t.name==="ok"&&(this.setName(i.querySelector(".t3js-grideditor-field-name").value,i.userData.col,i.userData.row),this.setColumn(parseInt(i.querySelector(".t3js-grideditor-field-colpos").value,10),i.userData.col,i.userData.row),this.setIdentifier(i.querySelector(".t3js-grideditor-field-identifier").value,i.userData.col,i.userData.row),this.setSlideMode(i.querySelector(".t3js-grideditor-field-slide-mode").value,i.userData.col,i.userData.row),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord()),i.hideModal())},this.addColumnHandler=e=>{e.preventDefault(),this.addColumn(),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.removeColumnHandler=e=>{e.preventDefault(),this.removeColumn(),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.addRowTopHandler=e=>{e.preventDefault(),this.addRowTop(),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.addRowBottomHandler=e=>{e.preventDefault(),this.addRowBottom(),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.removeRowTopHandler=e=>{e.preventDefault(),this.removeRowTop(),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.removeRowBottomHandler=e=>{e.preventDefault(),this.removeRowBottom(),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.linkEditorHandler=e=>{e.preventDefault();const t=e.currentTarget;this.showOptions(Number(t.dataset.col),Number(t.dataset.row))},this.linkExpandRightHandler=e=>{e.preventDefault();const t=e.currentTarget;this.addColspan(Number(t.dataset.col),Number(t.dataset.row)),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.linkShrinkLeftHandler=e=>{e.preventDefault();const t=e.currentTarget;this.removeColspan(Number(t.dataset.col),Number(t.dataset.row)),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.linkExpandDownHandler=e=>{e.preventDefault();const t=e.currentTarget;this.addRowspan(Number(t.dataset.col),Number(t.dataset.row)),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())},this.linkShrinkUpHandler=e=>{e.preventDefault();const t=e.currentTarget;this.removeRowspan(Number(t.dataset.col),Number(t.dataset.row)),this.requestUpdate(),this.writeConfig(this.export2LayoutRecord())}}static stripMarkup(e){return new G().stripHtml(e)}async connectedCallback(){await B.ready(),this.field=document.querySelector('input[name="'+this.fieldName+'"]'),this.addVisibilityObserver(this),super.connectedCallback()}firstUpdated(){this.writeConfig(this.export2LayoutRecord())}createRenderRoot(){return this}render(){return l`