UNPKG

@progress/kendo-vue-editor

Version:
92 lines (91 loc) 2.54 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { DropDownList as m } from "@progress/kendo-vue-dropdowns"; import { getBlockFormats as g, formatBlockElements as h } from "@progress/kendo-editor-common"; import { userSelectNone as v } from "./utils.mjs"; import { provideLocalizationService as y } from "@progress/kendo-vue-intl"; import { messages as I } from "../messages/main.mjs"; import { defineComponent as k, h as w } from "vue"; const L = /* @__PURE__ */ k({ name: "KendoFormatBlock", props: { view: Object, settings: { type: Object, default: function() { return { messages: {} }; } }, ...m.props }, inject: { kendoLocalizationService: { default: null } }, render() { const { view: e, render: o, dataItems: a, settings: n, defaultItem: s, ...d } = this.$props, l = a || n.items, r = e && e.state, c = r ? g(r) : [], i = new Set(c).size === 1 ? c[0] : null; let t = s || n.defaultItem; const p = y(this); t && t.localizationKey && (t = { ...t }, t.text = t.localizationKey ? p.toLanguageString(t.localizationKey, I[t.localizationKey]) : t.text); const u = { ...d, ...n.props, value: i && l.find((f) => f.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: v }; return w(m, u); }, methods: { customItemRender(e, o, a) { return a.dataItem.style ? e("li", { class: a.itemClass, onClick: a.onClick }, [e("span", { style: a.dataItem.style }, [...o.children])]) : o; }, onFormatBlockChange(e) { const { view: o, settings: a } = this.$props, n = e.target.value; if (o && h(n.value, a.commandName)(o.state, o.dispatch)) { const { event: s } = e; s && s.type === "click" && o.focus(); } } } }); export { L as FormatBlock };