

<script>
/* eslint-disable */
// sd-skip-auto-import
import cloneDeep from"lodash.clonedeep";import toolbarBtnMixin from"./toolbar-btn-mixin";import components from"./_import-components/sd-btn-text-format-import";var _render=function t(){var e=this,i=e._self._c;return i("span",[i("a-button",{class:{"sd-active":e.formatPainterData,"ant-btn-icon-only":true},attrs:{type:"link",title:"格式刷",disabled:1!==e.selectedCells.length},on:{click:e.formatPainter}},[i("a-icon",{attrs:{type:"sd-brush",theme:"filled"}})],1),i("a-button",{class:{"sd-active":e.activeBtn["bold"]},attrs:{type:"link",icon:"bold",title:"加粗"},on:{click:function(t){return e.format("fontWeight","bold","加粗")}}}),i("a-button",{class:{"sd-active":e.activeBtn["italic"]},attrs:{type:"link",icon:"italic",title:"斜体"},on:{click:function(t){return e.format("fontStyle","italic","斜体")}}}),i("a-button",{class:{"sd-active":e.activeBtn["underline"]},attrs:{id:"underline",type:"link",icon:"underline",title:"下划线"},on:{click:function(t){return e.format("textDecoration","underline","下划线")}}}),i("a-dropdown",{attrs:{trigger:["click"]},model:{value:e.visible,callback:function(t){e.visible=t},expression:"visible"}},[e.visible?i("div",{class:e.$style.dropContent,attrs:{slot:"overlay"},slot:"overlay"},[i("sd-color",{model:{value:e.colors,callback:function(t){e.colors=t},expression:"colors"}}),i("a-button",{on:{click:function(t){e.format("color","rgba(0, 0, 0, 0.65)")}}},[e._v("无填充")])],1):e._e(),i("a-button",{staticClass:"color-btn",attrs:{type:"link",icon:"font-colors",title:"颜色"},on:{click:function(t){return e.selectColor("color")}}})],1),i("a-dropdown",{attrs:{trigger:["click"]},model:{value:e.visible2,callback:function(t){e.visible2=t},expression:"visible2"}},[e.visible2?i("div",{class:e.$style.dropContent,attrs:{slot:"overlay"},slot:"overlay"},[i("sd-color",{model:{value:e.colors,callback:function(t){e.colors=t},expression:"colors"}}),i("a-button",{on:{click:function(t){return e.format("backgroundColor","transparent")}}},[e._v("无填充")])],1):e._e(),i("a-button",{staticClass:"color-btn",attrs:{type:"link",icon:"bg-colors",title:"背景色"},on:{click:function(t){return e.selectColor("backgroundColor")}}})],1),i("a-button",{class:{"sd-active":e.activeBtn["top"]},attrs:{type:"link",icon:"vertical-align-top",title:"顶部对齐"},on:{click:function(t){return e.format("verticalAlign","top","顶部对齐")}}}),i("a-button",{class:{"sd-active":e.activeBtn["middle"]},attrs:{type:"link",icon:"vertical-align-middle",title:"垂直居中对齐"},on:{click:function(t){return e.format("verticalAlign","middle","垂直居中对齐")}}}),i("a-button",{class:{"sd-active":e.activeBtn["bottom"]},attrs:{type:"link",icon:"vertical-align-bottom",title:"底部对齐"},on:{click:function(t){return e.format("verticalAlign","bottom","底部对齐")}}}),i("a-button",{class:{"sd-active":e.activeBtn["left"]},attrs:{type:"link",icon:"align-left",title:"左对齐"},on:{click:function(t){return e.format("textAlign","left","左对齐")}}}),i("a-button",{class:{"sd-active":e.activeBtn["right"]},attrs:{type:"link",icon:"align-right",title:"右对齐"},on:{click:function(t){return e.format("textAlign","right","右对齐")}}}),i("a-button",{class:{"sd-active":e.activeBtn["center"]},attrs:{type:"link",icon:"align-center",title:"居中"},on:{click:function(t){return e.format("textAlign","center","居中")}}})],1)};var staticRenderFns=[];_render._withStripped=true;export default{name:"SdBtnTextFormat",components:components,inject:["designer"],mixins:[toolbarBtnMixin],data(){return{colorType:"",showColor:false,formatPainterData:void 0,visible:false,visible2:false}},computed:{styleList(){return this.selectedCells.map((t=>this.tableData[t[0]][t[1]].style))},activeBtn(){const t=this.styleList.map((t=>Object.values(t))).flat().reduce(((t,e)=>{if(e in t)t[e]++;else t[e]=1;return t}),{});const e=Object.keys(t).reduce(((e,i)=>{if(t[i]===this.styleList.length)e[i]=t[i];return e}),{});return e},colors:{get(){const t=this.styleList.map((t=>t[this.colorType])).find(((t,e,i)=>i.lastIndexOf(t)-i.indexOf(t)===this.styleList.length-1));return t||""},set(t){this.format(this.colorType,t.hex8,"color"===this.colorType?"颜色":"背景色",false)}}},methods:{format(t,e,i,o=true){const n=this.styleList.map((e=>e[t]));this.selectedCells.forEach((i=>{const l=this.tableData[i[0]][i[1]];let a=l.style[t];if(1===n.length)a=a===e?void 0:e;else a=n.every((t=>t===e))?void 0:e;this.$set(l.style,t,o?a:e)}));this.designer.takeSnapshot(i)},selectColor(t){this.colorType=t;this.showColor=true},formatPainter(){this.formatPainterData=this.formatPainterData?void 0:cloneDeep(this.tableData[this.selectedCells[0][0]][this.selectedCells[0][1]].style)},onSelectFinish(t){if(!this.formatPainterData)return;t.forEach((t=>{this.tableData[t[0]][t[1]].style=cloneDeep(this.formatPainterData)}));this.formatPainterData=void 0;this.designer.takeSnapshot("格式刷")}},render:_render,staticRenderFns:staticRenderFns};</script>

<style module lang="scss">
@use '@/common/design' as *;
.drop-content {
  padding: 10px;
  background: $white;
  :global .ant-btn {
    width: 100%;
  }
}
</style>
