@progress/kendo-react-editor
Version:
React Editor enables users to create rich text content through a WYSIWYG interface. KendoReact Editor package
9 lines (8 loc) • 2.2 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 S=require("react"),d=require("@progress/kendo-editor-common"),p=require("@progress/kendo-react-buttons"),v=require("../config/toolsSettings.js"),k=require("@progress/kendo-react-intl"),T=require("../messages/index.js");function I(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return i.default=e,Object.freeze(i)}const f=I(S),m=(e,i)=>{const{from:t,to:o}=e.selection;let l=null;return e.doc.nodesBetween(t,o,a=>(l=l||(a.type===i?a:null),!l)),l},h=e=>{let i=!1;const t=e.view,o=v.listsTypes,l=e.listType,a=k.useLocalization();let y=[...e.items||[]],c,r;if(t){const s=t.state,n=s&&s.schema.nodes;c=n&&m(s,n[o.orderedList]),r=n&&m(s,n[o.bulletList]),i=!!(l===o.orderedList?c&&!r:!c&&r)}const g=s=>{t&&(d.toggleList(t.state,t.dispatch,t,{listType:l,...o,listAttrs:{}},"InsertList"),t.focus())},L=s=>{if(t){const n=s.item.style?{style:"list-style-type: "+s.item.style+";"}:{},u=c||r;if(u&&d.listStyle(u.attrs)!==s.item.style){const b=t.state.selection.$head.posAtIndex(0,-2)-1;t.dispatch(t.state.tr.setNodeMarkup(b,t.state.schema.nodes[l],n))}else d.toggleList(t.state,t.dispatch,t,{listType:l,...o,listAttrs:n},"InsertList");t.focus()}};if(i&&(c||r)){const s=d.listStyle((c||r).attrs);y=y.map((n,u)=>({...n,selected:s?n.style===s:u===0}))}return f.createElement("span",{onMouseDown:s=>{s.preventDefault()}},f.createElement(p.SplitButton,{textField:"text",items:y,icon:e.icon,svgIcon:e.svgIcon,onButtonClick:g,onItemClick:L,buttonClass:i?"k-selected":void 0,title:e.title!==void 0?e.title:a.toLanguageString(e.titleKey,T.messages[e.titleKey])}))};exports.ListTool=h;