UNPKG

@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.53 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),h=require("@progress/kendo-react-dialogs"),f=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-editor-common"),w=require("@progress/kendo-react-intl"),l=require("../messages/index.js"),y=require("../utils/props-key.js"),C=require("@progress/kendo-react-inputs");function A(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const i=A(v);let k=class extends i.Component{constructor(){super(...arguments),this.htmlArea=null,this.textAreaRef=e=>{this.htmlArea=e;const t=e&&e.element.current;t&&(t.style.resize="none")},this.onUpdate=()=>{const{view:e,settings:t}=this.props,o=r.trimWhitespace(this.htmlArea&&this.htmlArea.value||""),{preserveWhitespace:s}=y.editorPropsKey.getState(e.state);r.setHtml(o,t.commandName,{preserveWhitespace:s})(e.state,e.dispatch),this.onClose()},this.onClose=()=>{this.props.view.focus(),this.props.onClose()}}render(){const{view:e,settings:t,dir:o,render:s}=this.props,a=w.provideLocalizationService(this),{viewHtmlDialogTitle:c,viewHtmlCancel:u,viewHtmlUpdate:m}=t.messages,d=i.createElement(C.TextArea,{className:"k-editor-textarea",defaultValue:r.indentHtml(r.getHtml(e.state)),autoFocus:!0,autoSize:!1,ref:this.textAreaRef}),g=[i.createElement(f.Button,{onClick:this.onClose,dir:o,key:"cancel"},a.toLanguageString(u,l.messages[u])),i.createElement(f.Button,{onClick:this.onUpdate,themeColor:"primary",dir:o,key:"update"},a.toLanguageString(m,l.messages[m]))],p=i.createElement(h.Window,{className:"k-editor-window",title:a.toLanguageString(c,l.messages[c]),onClose:this.onClose,key:"dialog",style:o==="rtl"?{textAlign:"right"}:void 0,modal:!0,minimizeButton:()=>null,maximizeButton:()=>null,resizable:!0,initialHeight:400,initialWidth:500},d,i.createElement(h.WindowActionsBar,null,...g));return s?s(p,{content:d,actionButtons:g}):p}};w.registerForLocalization(k);exports.ViewHtmlDialog=k;