@progress/kendo-react-editor 13.3.0-develop.9 → 13.4.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/Editor.d.ts +125 -0
  2. package/Editor.js +1 -1
  3. package/Editor.mjs +77 -77
  4. package/EditorProps.d.ts +406 -0
  5. package/config/defaultStyles.d.ts +19 -0
  6. package/config/pasteSettings.d.ts +13 -0
  7. package/config/schema.d.ts +8 -0
  8. package/config/shortcuts.d.ts +31 -0
  9. package/config/shortcuts.mjs +7 -7
  10. package/config/toolsSettings.d.ts +496 -0
  11. package/dialogs/EditorDialogProps.d.ts +33 -0
  12. package/dialogs/FindReplace.d.ts +79 -0
  13. package/dialogs/FindReplace.mjs +3 -3
  14. package/dialogs/index.d.ts +56 -0
  15. package/dialogs/insertImage.d.ts +35 -0
  16. package/dialogs/insertImage.mjs +3 -3
  17. package/dialogs/insertLink.d.ts +33 -0
  18. package/dialogs/insertLink.mjs +3 -3
  19. package/dialogs/viewHtml.d.ts +32 -0
  20. package/dialogs/viewHtml.mjs +3 -3
  21. package/dist/cdn/js/kendo-react-editor.js +1 -1
  22. package/index.d.mts +176 -3134
  23. package/index.d.ts +176 -3134
  24. package/index.mjs +139 -139
  25. package/messages/index.d.ts +359 -0
  26. package/package-metadata.d.ts +12 -0
  27. package/package-metadata.js +1 -1
  28. package/package-metadata.mjs +10 -16
  29. package/package.json +12 -12
  30. package/tools/ToolProps.d.ts +41 -0
  31. package/tools/align.d.ts +14 -0
  32. package/tools/applyColor.d.ts +19 -0
  33. package/tools/cleanFormatting.d.ts +23 -0
  34. package/tools/findReplace.d.ts +36 -0
  35. package/tools/findReplace.mjs +3 -3
  36. package/tools/fontStyle.d.ts +35 -0
  37. package/tools/fontStyle.mjs +3 -3
  38. package/tools/formatBlock.d.ts +25 -0
  39. package/tools/formatBlock.mjs +3 -3
  40. package/tools/history.d.ts +33 -0
  41. package/tools/indent.d.ts +24 -0
  42. package/tools/index.d.ts +717 -0
  43. package/tools/index.mjs +1 -1
  44. package/tools/inlineFormat.d.ts +54 -0
  45. package/tools/inlineFormat.mjs +3 -3
  46. package/tools/insertImage.d.ts +20 -0
  47. package/tools/insertLink.d.ts +31 -0
  48. package/tools/insertTable/index.d.ts +10 -0
  49. package/tools/insertTable/popup.d.ts +100 -0
  50. package/tools/insertTable/popupGrid.d.ts +38 -0
  51. package/tools/insertTable/tool.d.ts +31 -0
  52. package/tools/lists-styled.d.ts +12 -0
  53. package/tools/lists.d.ts +34 -0
  54. package/tools/outdent.d.ts +24 -0
  55. package/tools/pdf.d.ts +32 -0
  56. package/tools/print.d.ts +23 -0
  57. package/tools/proseMirrorTool.d.ts +19 -0
  58. package/tools/selectAll.d.ts +23 -0
  59. package/tools/table-wizard/cellPropsUtils.d.ts +43 -0
  60. package/tools/table-wizard/cellPropsUtils.mjs +5 -5
  61. package/tools/table-wizard/tableCellProperties.d.ts +27 -0
  62. package/tools/table-wizard/tableProperties.d.ts +18 -0
  63. package/tools/table-wizard/tableProperties.mjs +13 -13
  64. package/tools/table-wizard/tablePropsUtils.d.ts +59 -0
  65. package/tools/table-wizard/tablePropsUtils.mjs +9 -9
  66. package/tools/table-wizard/utils.d.ts +46 -0
  67. package/tools/tableEdit.d.ts +105 -0
  68. package/tools/tableEdit.mjs +3 -3
  69. package/tools/unlink.d.ts +24 -0
  70. package/tools/utils.d.ts +57 -0
  71. package/tools/utils.mjs +1 -1
  72. package/tools/viewHtml.d.ts +31 -0
  73. package/utils/browser-detection.d.ts +11 -0
  74. package/utils/controlled-value.d.ts +12 -0
  75. package/utils/index.d.ts +370 -0
  76. package/utils/props-key.d.ts +12 -0
package/Editor.d.ts ADDED
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { default as PropTypes } from 'prop-types';
9
+ import { EditorView, Node } from '@progress/kendo-editor-common';
10
+ import { EditorProps } from './EditorProps.js';
11
+ import * as React from 'react';
12
+ /**
13
+ * @hidden
14
+ */
15
+ interface EditorStateInterface {
16
+ view?: EditorView;
17
+ linkDialog?: boolean;
18
+ }
19
+ /**
20
+ * Represents the [KendoReact Editor component](https://www.telerik.com/kendo-react-ui/components/editor).
21
+ *
22
+ * @example
23
+ * ```jsx
24
+ * const App = () => {
25
+ * return (
26
+ * <Editor
27
+ * defaultContent="<p>Hello World</p>"
28
+ * tools={[
29
+ * [ EditorTools.Bold, EditorTools.Italic ]
30
+ * ]}
31
+ * />
32
+ * );
33
+ * }
34
+ * ```
35
+ */
36
+ export declare class Editor extends React.Component<EditorProps, EditorStateInterface> {
37
+ /**
38
+ * @hidden
39
+ */
40
+ static propTypes: {
41
+ defaultContent: PropTypes.Requireable<string>;
42
+ value: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
43
+ defaultEditMode: PropTypes.Requireable<string>;
44
+ contentStyle: PropTypes.Requireable<object>;
45
+ dir: PropTypes.Requireable<string>;
46
+ className: PropTypes.Requireable<string>;
47
+ ariaDescribedBy: PropTypes.Requireable<string>;
48
+ ariaLabelledBy: PropTypes.Requireable<string>;
49
+ ariaLabel: PropTypes.Requireable<string>;
50
+ style: PropTypes.Requireable<object>;
51
+ tools: PropTypes.Requireable<any[]>;
52
+ keyboardNavigation: PropTypes.Requireable<boolean>;
53
+ resizable: PropTypes.Requireable<boolean>;
54
+ preserveWhitespace: PropTypes.Requireable<string | boolean>;
55
+ onMount: PropTypes.Requireable<(...args: any[]) => any>;
56
+ onFocus: PropTypes.Requireable<(...args: any[]) => any>;
57
+ onBlur: PropTypes.Requireable<(...args: any[]) => any>;
58
+ onChange: PropTypes.Requireable<(...args: any[]) => any>;
59
+ onPasteHtml: PropTypes.Requireable<(...args: any[]) => any>;
60
+ onExecute: PropTypes.Requireable<(...args: any[]) => any>;
61
+ onIFrameInit: PropTypes.Requireable<(...args: any[]) => any>;
62
+ };
63
+ /**
64
+ * @hidden
65
+ */
66
+ readonly state: EditorStateInterface;
67
+ /**
68
+ * The value of the Editor.
69
+ */
70
+ get value(): Node | string;
71
+ /**
72
+ * Returns the DOM element of the Editor.
73
+ */
74
+ get element(): HTMLElement | null;
75
+ /**
76
+ * Returns the content-editable DOM element of the Editor.
77
+ */
78
+ get contentElement(): HTMLDivElement | null;
79
+ /**
80
+ * Returns the `view` object of the Editor.
81
+ */
82
+ get view(): EditorView | undefined;
83
+ private _element;
84
+ private _view?;
85
+ private _contentElement;
86
+ private iframe;
87
+ private trOnChange;
88
+ private htmlOnChange;
89
+ private pasteEvent?;
90
+ private readonly showLicenseWatermark;
91
+ private readonly licenseMessage?;
92
+ constructor(props: EditorProps);
93
+ /**
94
+ * @hidden
95
+ */
96
+ componentDidMount(): void;
97
+ /**
98
+ * @hidden
99
+ */
100
+ componentDidUpdate(prevProps: EditorProps): void;
101
+ /**
102
+ * @hidden
103
+ */
104
+ componentWillUnmount(): void;
105
+ /**
106
+ * @hidden
107
+ */
108
+ focus: () => void;
109
+ /**
110
+ * @hidden
111
+ */
112
+ render(): React.JSX.Element;
113
+ private renderDialog;
114
+ private renderTool;
115
+ private updateTools;
116
+ private initialize;
117
+ private filterTransaction;
118
+ private onPasteHtml;
119
+ private dispatchTransaction;
120
+ private onFocus;
121
+ private onBlur;
122
+ private onPaste;
123
+ private onIFrameInit;
124
+ }
125
+ export {};
package/Editor.js CHANGED
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),i=require("prop-types"),b=require("@progress/kendo-react-buttons"),k=require("@progress/kendo-react-common"),n=require("@progress/kendo-editor-common"),_=require("./config/defaultStyles.js"),I=require("./config/toolsSettings.js"),L=require("./dialogs/index.js"),S=require("./utils/index.js"),D=require("./utils/props-key.js"),F=require("./utils/controlled-value.js"),M=require("./utils/browser-detection.js"),q=require("./package-metadata.js"),O=require("./messages/index.js"),x=require("@progress/kendo-react-intl");function W(m){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const e in m)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(m,e);Object.defineProperty(o,e,t.get?t:{enumerable:!0,get:()=>m[e]})}}return o.default=m,Object.freeze(o)}const c=W(B),{link:N,bold:z,italic:j,underline:H}=I.EditorToolsSettings,P=class P extends c.Component{constructor(o){super(o),this.state={view:void 0,linkDialog:!1},this._element=null,this._contentElement=null,this.iframe=null,this.trOnChange=null,this.htmlOnChange=null,this.showLicenseWatermark=!1,this.focus=()=>{this.view&&this.view.focus()},this.renderDialog=(e,t,s)=>this.state[s]&&c.createElement(e,{view:this.view,settings:t,dir:this.props.dir,onClose:()=>this.setState({[s]:!1})}),this.renderTool=(e,t,s=!1)=>{const d=c.createElement(e,{view:this.view,dir:this.props.dir,key:t,className:s?"k-toolbar-button":void 0});return d.type===b.ToolbarSeparator?c.createElement(e,{key:t}):d},this.updateTools=(e,t)=>{this.setState({view:e})},this.filterTransaction=(e,t)=>{const s={target:this,transaction:e,state:t};return(this.props.onExecute&&this.props.onExecute.call(void 0,s))!==!1},this.onPasteHtml=e=>{if(this.props.onPasteHtml&&this.pasteEvent){const t={target:this,pastedHtml:e,nativeEvent:this.pasteEvent},s=this.props.onPasteHtml.call(void 0,t);if(this.pasteEvent=void 0,typeof s=="string")return s}return e},this.dispatchTransaction=e=>{const t=e.docChanged;if(this.props.onChange&&t){this.trOnChange=e;const s=e.doc,d=e.doc.type.schema,u={target:this,value:s,html:"",transaction:e,schema:d};Object.defineProperty(u,"html",{get:()=>(this.htmlOnChange=S.EditorUtils.getHtml({doc:s,schema:d}),this.htmlOnChange)}),this.props.onChange.call(void 0,u)}this.view&&(this.props.value===void 0||!t)&&this.view.updateState(this.view.state.apply(e))},this.onFocus=(e,t)=>{if(this.props.onFocus){const s={target:this,nativeEvent:t};this.props.onFocus.call(void 0,s)}return!1},this.onBlur=(e,t)=>{if(this.props.onBlur){const s={target:this,nativeEvent:t};this.props.onBlur.call(void 0,s)}return!1},this.onPaste=(e,t)=>(this.props.onPasteHtml&&(this.pasteEvent=t),!1),this.onIFrameInit=e=>{if(this.props.onIFrameInit){const t={target:this,iframe:e};this.props.onIFrameInit.call(void 0,t)}return!1},this.showLicenseWatermark=!k.validatePackage(q.packageMetadata,{component:"Editor"}),this.licenseMessage=k.getLicenseMessage(q.packageMetadata)}get value(){return this.trOnChange!==null?this.trOnChange.doc:this.props.value!==void 0?this.props.value:this.view?this.view.state.doc:this.props.defaultContent||""}get element(){return this._element}get contentElement(){return this._contentElement}get view(){return this._view}componentDidMount(){(!this.iframe||!M.firefox)&&this.initialize()}componentDidUpdate(o){const{value:e}=this.props,t=this.view;e===void 0||!t||(F.updateEditorValue(t,e,o.value,this.trOnChange,this.htmlOnChange),this.trOnChange=null,this.htmlOnChange=null)}componentWillUnmount(){var e;this.view&&this.view.destroy(),this._view=void 0;const o=(e=this.iframe)==null?void 0:e.contentWindow;if(o){this._contentElement&&this._contentElement.parentNode&&this._contentElement.parentNode.removeChild(this._contentElement);const t=o.document.head;for(;t&&t.firstChild;)t.removeChild(t.firstChild)}}render(){const{tools:o=[],defaultEditMode:e="iframe",preserveWhitespace:t="full",style:s,className:d}=this.props,u=x.provideLocalizationService(this);if(this.view){const a=D.editorPropsKey.getState(this.view.state);a.preserveWhitespace=t}let p=this.props.contentStyle;p===void 0&&(s||{}).height===void 0&&(p={height:"300px"});const f=o.map((a,v)=>Array.isArray(a)?c.createElement(b.ButtonGroup,{key:v,className:"k-toolbar-button-group k-button-group-solid"},a.map((E,C)=>this.renderTool(E,C))):this.renderTool(a,v,!0));return c.createElement("div",{ref:a=>{this._element=a},className:k.classNames("k-editor",d,{"k-editor-resizable":this.props.resizable}),dir:this.props.dir,style:s},f.length>0&&c.createElement(b.Toolbar,{className:"k-editor-toolbar",keyboardNavigation:this.props.keyboardNavigation},f),e==="iframe"?c.createElement("div",{className:"k-editor-content"},c.createElement("iframe",{onLoad:M.firefox?()=>{this.initialize()}:void 0,ref:a=>{this.iframe=a},frameBorder:"0",title:u.toLanguageString(O.keys.iframeTitle,O.messages[O.keys.iframeTitle]),style:p,className:"k-iframe"})):c.createElement("div",{style:p,className:"k-editor-content"},c.createElement("div",{ref:a=>{this._contentElement=a},suppressContentEditableWarning:!0,role:"textbox","aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,"aria-label":this.props.ariaLabel})),this.renderDialog(L.EditorDialogs.InsertLinkDialog,N,"linkDialog"),this.showLicenseWatermark&&c.createElement(k.WatermarkOverlay,{message:this.licenseMessage}))}initialize(){const o=this.iframe&&this.iframe.contentWindow;if(o){const r=o.document,h=r.createElement("meta");h.setAttribute("charset","utf-8"),r.head.appendChild(h),this._contentElement=r.createElement("div"),r.body.appendChild(this._contentElement),this._contentElement.classList.add("k-content"),this.iframe&&this.props.onIFrameInit?this.onIFrameInit(this.iframe):[_.defaultStyle,_.tablesStyles,this.props.dir==="rtl"?_.rtlStyles:void 0].forEach(l=>{if(l){const g=r.createElement("style");g.appendChild(r.createTextNode(l)),r.head.appendChild(g)}})}const e=this._contentElement;if(!e)return;const{preserveWhitespace:t="full"}=this.props,s=[new n.Plugin({view:()=>({update:this.updateTools}),key:new n.PluginKey("toolbar-tools-update-plugin")}),new n.Plugin({filterTransaction:this.filterTransaction,key:new n.PluginKey("onExecute-event-plugin")}),new n.Plugin({key:D.editorPropsKey,state:{init:()=>({preserveWhitespace:t}),apply:(r,h)=>h}}),n.spacesFix(),n.caretColor(),n.history(),n.dropCursor(),n.gapCursor(),n.tableEditing(),n.cspFix()],d={...S.EditorUtils.getShortcuts({types:{listItem:"list_item",hardBreak:"hard_break"},toolsSettings:{bold:z,italic:j,underline:H}}),"Mod-k":()=>{const{linkDialog:r}=this.state,h=this.view;if(h){const l=h.state,g=l.selection.empty,y=n.getMark(l,l.schema.marks[N.mark]);!r&&!(g&&!y)&&this.setState({linkDialog:!0})}return!r},"Alt-F10":()=>{var h;const r=(h=this.element)==null?void 0:h.querySelector(".k-toolbar");if(r){const l=r.querySelector(b.toolbarButtons.join(","));if(l)return l.focus(),!0}return!1}},{defaultContent:u="",value:p,onMount:f}=this.props,a=p&&typeof p!="string"?p:S.EditorUtils.createDocument(new n.Schema({nodes:n.nodes,marks:n.marks}),p||u,{preserveWhitespace:t}),v={state:n.EditorState.create({plugins:[...s,n.keymap(d),n.keymap(n.baseKeymap)],doc:a}),transformPastedHTML:this.onPasteHtml,dispatchTransaction:this.dispatchTransaction,handleDOMEvents:{focus:this.onFocus,blur:this.onBlur,paste:this.onPaste},handleDrop:(r,h,l,g)=>{let y=!1;return l.content.nodesBetween(0,l.content.size,T=>{y=y||T.type.name==="table_caption_external"}),y}},E={plugins:s,shortcuts:d,target:this,viewProps:v,dom:e},C=this._view=f&&f.call(void 0,E)||new n.EditorView({mount:e},v);this.setState({view:C})}};P.propTypes={defaultContent:i.string,value:i.oneOfType([i.object,i.string]),defaultEditMode:i.oneOf(["iframe","div"]),contentStyle:i.object,dir:i.string,className:i.string,ariaDescribedBy:i.string,ariaLabelledBy:i.string,ariaLabel:i.string,style:i.object,tools:i.arrayOf(i.any),keyboardNavigation:i.bool,resizable:i.bool,preserveWhitespace:i.oneOf([!0,!1,"full"]),onMount:i.func,onFocus:i.func,onBlur:i.func,onChange:i.func,onPasteHtml:i.func,onExecute:i.func,onIFrameInit:i.func};let w=P;x.registerForLocalization(w);exports.Editor=w;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),i=require("prop-types"),w=require("@progress/kendo-react-buttons"),E=require("@progress/kendo-react-common"),n=require("@progress/kendo-editor-common"),_=require("./config/defaultStyles.js"),I=require("./config/toolsSettings.js"),L=require("./dialogs/index.js"),S=require("./utils/index.js"),D=require("./utils/props-key.js"),F=require("./utils/controlled-value.js"),M=require("./utils/browser-detection.js"),N=require("./package-metadata.js"),O=require("./messages/index.js"),x=require("@progress/kendo-react-intl");function W(v){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(v){for(const e in v)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(v,e);Object.defineProperty(a,e,t.get?t:{enumerable:!0,get:()=>v[e]})}}return a.default=v,Object.freeze(a)}const h=W(B),{link:q,bold:j,italic:z,underline:H}=I.EditorToolsSettings,P=class P extends h.Component{constructor(a){super(a),this.state={view:void 0,linkDialog:!1},this._element=null,this._contentElement=null,this.iframe=null,this.trOnChange=null,this.htmlOnChange=null,this.showLicenseWatermark=!1,this.focus=()=>{this.view&&this.view.focus()},this.renderDialog=(e,t,s)=>this.state[s]&&h.createElement(e,{view:this.view,settings:t,dir:this.props.dir,onClose:()=>this.setState({[s]:!1})}),this.renderTool=(e,t,s=!1)=>{const d=h.createElement(e,{view:this.view,dir:this.props.dir,key:t,className:s?"k-toolbar-button":void 0});return d.type===w.ToolbarSeparator?h.createElement(e,{key:t}):d},this.updateTools=(e,t)=>{this.setState({view:e})},this.filterTransaction=(e,t)=>{const s={target:this,transaction:e,state:t};return(this.props.onExecute&&this.props.onExecute.call(void 0,s))!==!1},this.onPasteHtml=e=>{if(this.props.onPasteHtml&&this.pasteEvent){const t={target:this,pastedHtml:e,nativeEvent:this.pasteEvent},s=this.props.onPasteHtml.call(void 0,t);if(this.pasteEvent=void 0,typeof s=="string")return s}return e},this.dispatchTransaction=e=>{const t=e.docChanged;if(this.props.onChange&&t){this.trOnChange=e;const s=e.doc,d=e.doc.type.schema,m={target:this,value:s,html:"",transaction:e,schema:d};Object.defineProperty(m,"html",{get:()=>(this.htmlOnChange=S.EditorUtils.getHtml({doc:s,schema:d}),this.htmlOnChange)}),this.props.onChange.call(void 0,m)}this.view&&(this.props.value===void 0||!t)&&this.view.updateState(this.view.state.apply(e))},this.onFocus=(e,t)=>{if(this.props.onFocus){const s={target:this,nativeEvent:t};this.props.onFocus.call(void 0,s)}return!1},this.onBlur=(e,t)=>{if(this.props.onBlur){const s={target:this,nativeEvent:t};this.props.onBlur.call(void 0,s)}return!1},this.onPaste=(e,t)=>(this.props.onPasteHtml&&(this.pasteEvent=t),!1),this.onIFrameInit=e=>{if(this.props.onIFrameInit){const t={target:this,iframe:e};this.props.onIFrameInit.call(void 0,t)}return!1},this.showLicenseWatermark=!E.validatePackage(N.packageMetadata,{component:"Editor"}),this.licenseMessage=E.getLicenseMessage(N.packageMetadata)}get value(){return this.trOnChange!==null?this.trOnChange.doc:this.props.value!==void 0?this.props.value:this.view?this.view.state.doc:this.props.defaultContent||""}get element(){return this._element}get contentElement(){return this._contentElement}get view(){return this._view}componentDidMount(){(!this.iframe||!M.firefox)&&this.initialize()}componentDidUpdate(a){const{value:e}=this.props,t=this.view;e===void 0||!t||(F.updateEditorValue(t,e,a.value,this.trOnChange,this.htmlOnChange),this.trOnChange=null,this.htmlOnChange=null)}componentWillUnmount(){var e;this.view&&this.view.destroy(),this._view=void 0;const a=(e=this.iframe)==null?void 0:e.contentWindow;if(a){this._contentElement&&this._contentElement.parentNode&&this._contentElement.parentNode.removeChild(this._contentElement);const t=a.document.head;for(;t&&t.firstChild;)t.removeChild(t.firstChild)}}render(){const{tools:a=[],defaultEditMode:e="iframe",preserveWhitespace:t="full",style:s,className:d}=this.props,m=x.provideLocalizationService(this);if(this.view){const o=D.editorPropsKey.getState(this.view.state);o.preserveWhitespace=t}let p=this.props.contentStyle;p===void 0&&(s||{}).height===void 0&&(p={height:"300px"});const f=(o,u)=>o.displayName||o.name||`tool-${u}`,C=(o,u)=>o.map((r,l)=>f(r,l)).join("-")||`group-${u}`,g=a.map((o,u)=>Array.isArray(o)?h.createElement(w.ButtonGroup,{key:C(o,u),className:"k-toolbar-button-group"},o.map((r,l)=>this.renderTool(r,f(r,l)))):this.renderTool(o,f(o,u),!0));return h.createElement("div",{ref:o=>{this._element=o},className:E.classNames("k-editor",d,{"k-editor-resizable":this.props.resizable}),dir:this.props.dir,style:s},g.length>0&&h.createElement(w.Toolbar,{className:"k-editor-toolbar",keyboardNavigation:this.props.keyboardNavigation},g),e==="iframe"?h.createElement("div",{className:"k-editor-content"},h.createElement("iframe",{onLoad:M.firefox?()=>{this.initialize()}:void 0,ref:o=>{this.iframe=o},frameBorder:"0",title:m.toLanguageString(O.keys.iframeTitle,O.messages[O.keys.iframeTitle]),style:p,className:"k-iframe"})):h.createElement("div",{style:p,className:"k-editor-content"},h.createElement("div",{ref:o=>{this._contentElement=o},suppressContentEditableWarning:!0,role:"textbox","aria-labelledby":this.props.ariaLabelledBy,"aria-describedby":this.props.ariaDescribedBy,"aria-label":this.props.ariaLabel})),this.renderDialog(L.EditorDialogs.InsertLinkDialog,q,"linkDialog"),this.showLicenseWatermark&&h.createElement(E.WatermarkOverlay,{message:this.licenseMessage}))}initialize(){const a=this.iframe&&this.iframe.contentWindow;if(a){const r=a.document,l=r.createElement("meta");l.setAttribute("charset","utf-8"),r.head.appendChild(l),this._contentElement=r.createElement("div"),r.body.appendChild(this._contentElement),this._contentElement.classList.add("k-content"),this.iframe&&this.props.onIFrameInit?this.onIFrameInit(this.iframe):[_.defaultStyle,_.tablesStyles,this.props.dir==="rtl"?_.rtlStyles:void 0].forEach(c=>{if(c){const y=r.createElement("style");y.appendChild(r.createTextNode(c)),r.head.appendChild(y)}})}const e=this._contentElement;if(!e)return;const{preserveWhitespace:t="full"}=this.props,s=[new n.Plugin({view:(()=>({update:this.updateTools})),key:new n.PluginKey("toolbar-tools-update-plugin")}),new n.Plugin({filterTransaction:this.filterTransaction,key:new n.PluginKey("onExecute-event-plugin")}),new n.Plugin({key:D.editorPropsKey,state:{init:()=>({preserveWhitespace:t}),apply:(r,l)=>l}}),n.spacesFix(),n.caretColor(),n.history(),n.dropCursor(),n.gapCursor(),n.tableEditing(),n.cspFix()],d={...S.EditorUtils.getShortcuts({types:{listItem:"list_item",hardBreak:"hard_break"},toolsSettings:{bold:j,italic:z,underline:H}}),"Mod-k":()=>{const{linkDialog:r}=this.state,l=this.view;if(l){const c=l.state,y=c.selection.empty,b=n.getMark(c,c.schema.marks[q.mark]);!r&&!(y&&!b)&&this.setState({linkDialog:!0})}return!r},"Alt-F10":()=>{var l;const r=(l=this.element)==null?void 0:l.querySelector(".k-toolbar");if(r){const c=r.querySelector(w.toolbarButtons.join(","));if(c)return c.focus(),!0}return!1}},{defaultContent:m="",value:p,onMount:f}=this.props,C=p&&typeof p!="string"?p:S.EditorUtils.createDocument(new n.Schema({nodes:n.nodes,marks:n.marks}),p||m,{preserveWhitespace:t}),g={state:n.EditorState.create({plugins:[...s,n.keymap(d),n.keymap(n.baseKeymap)],doc:C}),transformPastedHTML:this.onPasteHtml,dispatchTransaction:this.dispatchTransaction,handleDOMEvents:{focus:this.onFocus,blur:this.onBlur,paste:this.onPaste},handleDrop:(r,l,c,y)=>{let b=!1;return c.content.nodesBetween(0,c.content.size,T=>{b=b||T.type.name==="table_caption_external"}),b}},o={plugins:s,shortcuts:d,target:this,viewProps:g,dom:e},u=this._view=f&&f.call(void 0,o)||new n.EditorView({mount:e},g);this.setState({view:u})}};P.propTypes={defaultContent:i.string,value:i.oneOfType([i.object,i.string]),defaultEditMode:i.oneOf(["iframe","div"]),contentStyle:i.object,dir:i.string,className:i.string,ariaDescribedBy:i.string,ariaLabelledBy:i.string,ariaLabel:i.string,style:i.object,tools:i.arrayOf(i.any),keyboardNavigation:i.bool,resizable:i.bool,preserveWhitespace:i.oneOf([!0,!1,"full"]),onMount:i.func,onFocus:i.func,onBlur:i.func,onChange:i.func,onPasteHtml:i.func,onExecute:i.func,onIFrameInit:i.func};let k=P;x.registerForLocalization(k);exports.Editor=k;
package/Editor.mjs CHANGED
@@ -5,29 +5,29 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as a from "react";
8
+ import * as l from "react";
9
9
  import i from "prop-types";
10
10
  import { ToolbarSeparator as L, ButtonGroup as B, Toolbar as F, toolbarButtons as I } from "@progress/kendo-react-buttons";
11
11
  import { validatePackage as M, getLicenseMessage as W, classNames as x, WatermarkOverlay as z } from "@progress/kendo-react-common";
12
- import { Plugin as b, PluginKey as _, spacesFix as H, caretColor as j, history as A, dropCursor as V, gapCursor as K, tableEditing as U, cspFix as q, getMark as G, Schema as R, nodes as J, marks as Q, EditorState as X, keymap as S, baseKeymap as Y, EditorView as Z } from "@progress/kendo-editor-common";
13
- import { defaultStyle as $, tablesStyles as tt, rtlStyles as et } from "./config/defaultStyles.mjs";
12
+ import { Plugin as w, spacesFix as H, caretColor as j, history as K, dropCursor as A, gapCursor as V, tableEditing as U, cspFix as q, PluginKey as _, Schema as G, marks as $, nodes as R, EditorState as J, keymap as S, baseKeymap as Q, EditorView as X, getMark as Y } from "@progress/kendo-editor-common";
13
+ import { defaultStyle as Z, tablesStyles as tt, rtlStyles as et } from "./config/defaultStyles.mjs";
14
14
  import { EditorToolsSettings as it } from "./config/toolsSettings.mjs";
15
15
  import { EditorDialogs as st } from "./dialogs/index.mjs";
16
- import { EditorUtils as w } from "./utils/index.mjs";
16
+ import { EditorUtils as b } from "./utils/index.mjs";
17
17
  import { editorPropsKey as T } from "./utils/props-key.mjs";
18
18
  import { updateEditorValue as ot } from "./utils/controlled-value.mjs";
19
19
  import { firefox as O } from "./utils/browser-detection.mjs";
20
- import { packageMetadata as P } from "./package-metadata.mjs";
21
- import { keys as D, messages as nt } from "./messages/index.mjs";
20
+ import { packageMetadata as N } from "./package-metadata.mjs";
21
+ import { keys as P, messages as nt } from "./messages/index.mjs";
22
22
  import { provideLocalizationService as rt, registerForLocalization as at } from "@progress/kendo-react-intl";
23
- const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends a.Component {
24
- constructor(l) {
25
- super(l), this.state = {
23
+ const { link: D, bold: lt, italic: ht, underline: ct } = it, k = class k extends l.Component {
24
+ constructor(h) {
25
+ super(h), this.state = {
26
26
  view: void 0,
27
27
  linkDialog: !1
28
28
  }, this._element = null, this._contentElement = null, this.iframe = null, this.trOnChange = null, this.htmlOnChange = null, this.showLicenseWatermark = !1, this.focus = () => {
29
29
  this.view && this.view.focus();
30
- }, this.renderDialog = (t, e, s) => this.state[s] && /* @__PURE__ */ a.createElement(
30
+ }, this.renderDialog = (t, e, s) => this.state[s] && /* @__PURE__ */ l.createElement(
31
31
  t,
32
32
  {
33
33
  view: this.view,
@@ -36,7 +36,7 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
36
36
  onClose: () => this.setState({ [s]: !1 })
37
37
  }
38
38
  ), this.renderTool = (t, e, s = !1) => {
39
- const c = /* @__PURE__ */ a.createElement(
39
+ const c = /* @__PURE__ */ l.createElement(
40
40
  t,
41
41
  {
42
42
  view: this.view,
@@ -45,7 +45,7 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
45
45
  className: s ? "k-toolbar-button" : void 0
46
46
  }
47
47
  );
48
- return c.type === L ? /* @__PURE__ */ a.createElement(t, { key: e }) : c;
48
+ return c.type === L ? /* @__PURE__ */ l.createElement(t, { key: e }) : c;
49
49
  }, this.updateTools = (t, e) => {
50
50
  this.setState({ view: t });
51
51
  }, this.filterTransaction = (t, e) => {
@@ -66,16 +66,16 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
66
66
  const e = t.docChanged;
67
67
  if (this.props.onChange && e) {
68
68
  this.trOnChange = t;
69
- const s = t.doc, c = t.doc.type.schema, d = {
69
+ const s = t.doc, c = t.doc.type.schema, m = {
70
70
  target: this,
71
71
  value: s,
72
72
  html: "",
73
73
  transaction: t,
74
74
  schema: c
75
75
  };
76
- Object.defineProperty(d, "html", {
77
- get: () => (this.htmlOnChange = w.getHtml({ doc: s, schema: c }), this.htmlOnChange)
78
- }), this.props.onChange.call(void 0, d);
76
+ Object.defineProperty(m, "html", {
77
+ get: () => (this.htmlOnChange = b.getHtml({ doc: s, schema: c }), this.htmlOnChange)
78
+ }), this.props.onChange.call(void 0, m);
79
79
  }
80
80
  this.view && (this.props.value === void 0 || !e) && this.view.updateState(this.view.state.apply(t));
81
81
  }, this.onFocus = (t, e) => {
@@ -105,7 +105,7 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
105
105
  this.props.onIFrameInit.call(void 0, e);
106
106
  }
107
107
  return !1;
108
- }, this.showLicenseWatermark = !M(P, { component: "Editor" }), this.licenseMessage = W(P);
108
+ }, this.showLicenseWatermark = !M(N, { component: "Editor" }), this.licenseMessage = W(N);
109
109
  }
110
110
  /**
111
111
  * The value of the Editor.
@@ -140,9 +140,9 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
140
140
  /**
141
141
  * @hidden
142
142
  */
143
- componentDidUpdate(l) {
143
+ componentDidUpdate(h) {
144
144
  const { value: t } = this.props, e = this.view;
145
- t === void 0 || !e || (ot(e, t, l.value, this.trOnChange, this.htmlOnChange), this.trOnChange = null, this.htmlOnChange = null);
145
+ t === void 0 || !e || (ot(e, t, h.value, this.trOnChange, this.htmlOnChange), this.trOnChange = null, this.htmlOnChange = null);
146
146
  }
147
147
  /**
148
148
  * @hidden
@@ -150,10 +150,10 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
150
150
  componentWillUnmount() {
151
151
  var t;
152
152
  this.view && this.view.destroy(), this._view = void 0;
153
- const l = (t = this.iframe) == null ? void 0 : t.contentWindow;
154
- if (l) {
153
+ const h = (t = this.iframe) == null ? void 0 : t.contentWindow;
154
+ if (h) {
155
155
  this._contentElement && this._contentElement.parentNode && this._contentElement.parentNode.removeChild(this._contentElement);
156
- const e = l.document.head;
156
+ const e = h.document.head;
157
157
  for (; e && e.firstChild; )
158
158
  e.removeChild(e.firstChild);
159
159
  }
@@ -162,46 +162,46 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
162
162
  * @hidden
163
163
  */
164
164
  render() {
165
- const { tools: l = [], defaultEditMode: t = "iframe", preserveWhitespace: e = "full", style: s, className: c } = this.props, d = rt(this);
165
+ const { tools: h = [], defaultEditMode: t = "iframe", preserveWhitespace: e = "full", style: s, className: c } = this.props, m = rt(this);
166
166
  if (this.view) {
167
- const n = T.getState(this.view.state);
168
- n.preserveWhitespace = e;
167
+ const o = T.getState(this.view.state);
168
+ o.preserveWhitespace = e;
169
169
  }
170
170
  let p = this.props.contentStyle;
171
171
  p === void 0 && (s || {}).height === void 0 && (p = { height: "300px" });
172
- const m = l.map(
173
- (n, u) => Array.isArray(n) ? /* @__PURE__ */ a.createElement(B, { key: u, className: "k-toolbar-button-group k-button-group-solid" }, n.map((g, y) => this.renderTool(g, y))) : this.renderTool(n, u, !0)
172
+ const u = (o, d) => o.displayName || o.name || `tool-${d}`, y = (o, d) => o.map((n, r) => u(n, r)).join("-") || `group-${d}`, f = h.map(
173
+ (o, d) => Array.isArray(o) ? /* @__PURE__ */ l.createElement(B, { key: y(o, d), className: "k-toolbar-button-group" }, o.map((n, r) => this.renderTool(n, u(n, r)))) : this.renderTool(o, u(o, d), !0)
174
174
  );
175
- return /* @__PURE__ */ a.createElement(
175
+ return /* @__PURE__ */ l.createElement(
176
176
  "div",
177
177
  {
178
- ref: (n) => {
179
- this._element = n;
178
+ ref: (o) => {
179
+ this._element = o;
180
180
  },
181
181
  className: x("k-editor", c, { "k-editor-resizable": this.props.resizable }),
182
182
  dir: this.props.dir,
183
183
  style: s
184
184
  },
185
- m.length > 0 && /* @__PURE__ */ a.createElement(F, { className: "k-editor-toolbar", keyboardNavigation: this.props.keyboardNavigation }, m),
186
- t === "iframe" ? /* @__PURE__ */ a.createElement("div", { className: "k-editor-content" }, /* @__PURE__ */ a.createElement(
185
+ f.length > 0 && /* @__PURE__ */ l.createElement(F, { className: "k-editor-toolbar", keyboardNavigation: this.props.keyboardNavigation }, f),
186
+ t === "iframe" ? /* @__PURE__ */ l.createElement("div", { className: "k-editor-content" }, /* @__PURE__ */ l.createElement(
187
187
  "iframe",
188
188
  {
189
189
  onLoad: O ? () => {
190
190
  this.initialize();
191
191
  } : void 0,
192
- ref: (n) => {
193
- this.iframe = n;
192
+ ref: (o) => {
193
+ this.iframe = o;
194
194
  },
195
195
  frameBorder: "0",
196
- title: d.toLanguageString(D.iframeTitle, nt[D.iframeTitle]),
196
+ title: m.toLanguageString(P.iframeTitle, nt[P.iframeTitle]),
197
197
  style: p,
198
198
  className: "k-iframe"
199
199
  }
200
- )) : /* @__PURE__ */ a.createElement("div", { style: p, className: "k-editor-content" }, /* @__PURE__ */ a.createElement(
200
+ )) : /* @__PURE__ */ l.createElement("div", { style: p, className: "k-editor-content" }, /* @__PURE__ */ l.createElement(
201
201
  "div",
202
202
  {
203
- ref: (n) => {
204
- this._contentElement = n;
203
+ ref: (o) => {
204
+ this._contentElement = o;
205
205
  },
206
206
  suppressContentEditableWarning: !0,
207
207
  role: "textbox",
@@ -210,18 +210,18 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
210
210
  "aria-label": this.props.ariaLabel
211
211
  }
212
212
  )),
213
- this.renderDialog(st.InsertLinkDialog, N, "linkDialog"),
214
- this.showLicenseWatermark && /* @__PURE__ */ a.createElement(z, { message: this.licenseMessage })
213
+ this.renderDialog(st.InsertLinkDialog, D, "linkDialog"),
214
+ this.showLicenseWatermark && /* @__PURE__ */ l.createElement(z, { message: this.licenseMessage })
215
215
  );
216
216
  }
217
217
  initialize() {
218
- const l = this.iframe && this.iframe.contentWindow;
219
- if (l) {
220
- const o = l.document, h = o.createElement("meta");
221
- h.setAttribute("charset", "utf-8"), o.head.appendChild(h), this._contentElement = o.createElement("div"), o.body.appendChild(this._contentElement), this._contentElement.classList.add("k-content"), this.iframe && this.props.onIFrameInit ? this.onIFrameInit(this.iframe) : [$, tt, this.props.dir === "rtl" ? et : void 0].forEach((r) => {
222
- if (r) {
223
- const f = o.createElement("style");
224
- f.appendChild(o.createTextNode(r)), o.head.appendChild(f);
218
+ const h = this.iframe && this.iframe.contentWindow;
219
+ if (h) {
220
+ const n = h.document, r = n.createElement("meta");
221
+ r.setAttribute("charset", "utf-8"), n.head.appendChild(r), this._contentElement = n.createElement("div"), n.body.appendChild(this._contentElement), this._contentElement.classList.add("k-content"), this.iframe && this.props.onIFrameInit ? this.onIFrameInit(this.iframe) : [Z, tt, this.props.dir === "rtl" ? et : void 0].forEach((a) => {
222
+ if (a) {
223
+ const v = n.createElement("style");
224
+ v.appendChild(n.createTextNode(a)), n.head.appendChild(v);
225
225
  }
226
226
  });
227
227
  }
@@ -230,57 +230,57 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
230
230
  return;
231
231
  const { preserveWhitespace: e = "full" } = this.props, s = [
232
232
  // https://prosemirror.net/docs/ref/#state.PluginSpec
233
- new b({
234
- view: () => ({ update: this.updateTools }),
233
+ new w({
234
+ view: (() => ({ update: this.updateTools })),
235
235
  key: new _("toolbar-tools-update-plugin")
236
236
  }),
237
- new b({
237
+ new w({
238
238
  filterTransaction: this.filterTransaction,
239
239
  key: new _("onExecute-event-plugin")
240
240
  }),
241
- new b({
241
+ new w({
242
242
  key: T,
243
243
  state: {
244
244
  init: () => ({ preserveWhitespace: e }),
245
- apply: (o, h) => h
245
+ apply: (n, r) => r
246
246
  }
247
247
  }),
248
248
  H(),
249
249
  j(),
250
+ K(),
250
251
  A(),
251
252
  V(),
252
- K(),
253
253
  U(),
254
254
  q()
255
255
  ], c = {
256
- ...w.getShortcuts({
256
+ ...b.getShortcuts({
257
257
  types: { listItem: "list_item", hardBreak: "hard_break" },
258
258
  toolsSettings: { bold: lt, italic: ht, underline: ct }
259
259
  }),
260
260
  "Mod-k": () => {
261
- const { linkDialog: o } = this.state, h = this.view;
262
- if (h) {
263
- const r = h.state, f = r.selection.empty, v = G(r, r.schema.marks[N.mark]);
264
- !o && !(f && !v) && this.setState({ linkDialog: !0 });
261
+ const { linkDialog: n } = this.state, r = this.view;
262
+ if (r) {
263
+ const a = r.state, v = a.selection.empty, g = Y(a, a.schema.marks[D.mark]);
264
+ !n && !(v && !g) && this.setState({ linkDialog: !0 });
265
265
  }
266
- return !o;
266
+ return !n;
267
267
  },
268
268
  "Alt-F10": () => {
269
- var h;
270
- const o = (h = this.element) == null ? void 0 : h.querySelector(".k-toolbar");
271
- if (o) {
272
- const r = o.querySelector(I.join(","));
273
- if (r)
274
- return r.focus(), !0;
269
+ var r;
270
+ const n = (r = this.element) == null ? void 0 : r.querySelector(".k-toolbar");
271
+ if (n) {
272
+ const a = n.querySelector(I.join(","));
273
+ if (a)
274
+ return a.focus(), !0;
275
275
  }
276
276
  return !1;
277
277
  }
278
- }, { defaultContent: d = "", value: p, onMount: m } = this.props, n = p && typeof p != "string" ? p : w.createDocument(new R({ nodes: J, marks: Q }), p || d, {
278
+ }, { defaultContent: m = "", value: p, onMount: u } = this.props, y = p && typeof p != "string" ? p : b.createDocument(new G({ nodes: R, marks: $ }), p || m, {
279
279
  preserveWhitespace: e
280
- }), u = {
281
- state: X.create({
282
- plugins: [...s, S(c), S(Y)],
283
- doc: n
280
+ }), f = {
281
+ state: J.create({
282
+ plugins: [...s, S(c), S(Q)],
283
+ doc: y
284
284
  }),
285
285
  transformPastedHTML: this.onPasteHtml,
286
286
  dispatchTransaction: this.dispatchTransaction,
@@ -289,15 +289,15 @@ const { link: N, bold: lt, italic: ht, underline: ct } = it, k = class k extends
289
289
  blur: this.onBlur,
290
290
  paste: this.onPaste
291
291
  },
292
- handleDrop: (o, h, r, f) => {
293
- let v = !1;
294
- return r.content.nodesBetween(0, r.content.size, (C) => {
295
- v = v || C.type.name === "table_caption_external";
296
- }), v;
292
+ handleDrop: (n, r, a, v) => {
293
+ let g = !1;
294
+ return a.content.nodesBetween(0, a.content.size, (C) => {
295
+ g = g || C.type.name === "table_caption_external";
296
+ }), g;
297
297
  }
298
- }, g = { plugins: s, shortcuts: c, target: this, viewProps: u, dom: t }, y = this._view = m && m.call(void 0, g) || new Z({ mount: t }, u);
298
+ }, o = { plugins: s, shortcuts: c, target: this, viewProps: f, dom: t }, d = this._view = u && u.call(void 0, o) || new X({ mount: t }, f);
299
299
  this.setState({
300
- view: y
300
+ view: d
301
301
  });
302
302
  }
303
303
  };