@progress/kendo-vue-editor
Version:
9 lines (8 loc) • 1.93 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@progress/kendo-vue-dropdowns"),u=require("@progress/kendo-editor-common"),h=require("./utils.js"),k=require("@progress/kendo-vue-intl"),y=require("../messages/main.js"),m=require("vue"),I=m.defineComponent({name:"KendoFormatBlock",props:{view:Object,settings:{type:Object,default:function(){return{messages:{}}}},...d.DropDownList.props},inject:{kendoLocalizationService:{default:null}},render(){const{view:e,render:o,dataItems:n,settings:s,defaultItem:a,...p}=this.$props,l=n||s.items,r=e&&e.state,c=r?u.getBlockFormats(r):[],i=new Set(c).size===1?c[0]:null;let t=a||s.defaultItem;const f=k.provideLocalizationService(this);t&&t.localizationKey&&(t={...t},t.text=t.localizationKey?f.toLanguageString(t.localizationKey,y.messages[t.localizationKey]):t.text);const g={...p,...s.props,value:i&&l.find(v=>v.value===i),dataItems:l,defaultItem:t,itemRender:this.customItemRender,textField:"text",dataItemKey:"value",leftRightKeysNavigation:!1,popupSettings:{width:"170px"},title:t.text,onChange:this.onFormatBlockChange,style:h.userSelectNone};return m.h(d.DropDownList,g)},methods:{customItemRender(e,o,n){return n.dataItem.style?e("li",{class:n.itemClass,onClick:n.onClick},[e("span",{style:n.dataItem.style},[...o.children])]):o},onFormatBlockChange(e){const{view:o,settings:n}=this.$props,s=e.target.value;if(o&&u.formatBlockElements(s.value,n.commandName)(o.state,o.dispatch)){const{event:a}=e;a&&a.type==="click"&&o.focus()}}}});exports.FormatBlock=I;