@progress/kendo-react-editor 13.3.0 → 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.
- package/Editor.d.ts +125 -0
- package/Editor.js +1 -1
- package/Editor.mjs +77 -77
- package/EditorProps.d.ts +406 -0
- package/config/defaultStyles.d.ts +19 -0
- package/config/pasteSettings.d.ts +13 -0
- package/config/schema.d.ts +8 -0
- package/config/shortcuts.d.ts +31 -0
- package/config/shortcuts.mjs +7 -7
- package/config/toolsSettings.d.ts +496 -0
- package/dialogs/EditorDialogProps.d.ts +33 -0
- package/dialogs/FindReplace.d.ts +79 -0
- package/dialogs/FindReplace.mjs +3 -3
- package/dialogs/index.d.ts +56 -0
- package/dialogs/insertImage.d.ts +35 -0
- package/dialogs/insertImage.mjs +3 -3
- package/dialogs/insertLink.d.ts +33 -0
- package/dialogs/insertLink.mjs +3 -3
- package/dialogs/viewHtml.d.ts +32 -0
- package/dialogs/viewHtml.mjs +3 -3
- package/dist/cdn/js/kendo-react-editor.js +1 -1
- package/index.d.mts +176 -3134
- package/index.d.ts +176 -3134
- package/index.mjs +139 -139
- package/messages/index.d.ts +359 -0
- package/package-metadata.d.ts +12 -0
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +10 -16
- package/package.json +12 -12
- package/tools/ToolProps.d.ts +41 -0
- package/tools/align.d.ts +14 -0
- package/tools/applyColor.d.ts +19 -0
- package/tools/cleanFormatting.d.ts +23 -0
- package/tools/findReplace.d.ts +36 -0
- package/tools/findReplace.mjs +3 -3
- package/tools/fontStyle.d.ts +35 -0
- package/tools/fontStyle.mjs +3 -3
- package/tools/formatBlock.d.ts +25 -0
- package/tools/formatBlock.mjs +3 -3
- package/tools/history.d.ts +33 -0
- package/tools/indent.d.ts +24 -0
- package/tools/index.d.ts +717 -0
- package/tools/index.mjs +1 -1
- package/tools/inlineFormat.d.ts +54 -0
- package/tools/inlineFormat.mjs +3 -3
- package/tools/insertImage.d.ts +20 -0
- package/tools/insertLink.d.ts +31 -0
- package/tools/insertTable/index.d.ts +10 -0
- package/tools/insertTable/popup.d.ts +100 -0
- package/tools/insertTable/popupGrid.d.ts +38 -0
- package/tools/insertTable/tool.d.ts +31 -0
- package/tools/lists-styled.d.ts +12 -0
- package/tools/lists.d.ts +34 -0
- package/tools/outdent.d.ts +24 -0
- package/tools/pdf.d.ts +32 -0
- package/tools/print.d.ts +23 -0
- package/tools/proseMirrorTool.d.ts +19 -0
- package/tools/selectAll.d.ts +23 -0
- package/tools/table-wizard/cellPropsUtils.d.ts +43 -0
- package/tools/table-wizard/cellPropsUtils.mjs +5 -5
- package/tools/table-wizard/tableCellProperties.d.ts +27 -0
- package/tools/table-wizard/tableProperties.d.ts +18 -0
- package/tools/table-wizard/tableProperties.mjs +13 -13
- package/tools/table-wizard/tablePropsUtils.d.ts +59 -0
- package/tools/table-wizard/tablePropsUtils.mjs +9 -9
- package/tools/table-wizard/utils.d.ts +46 -0
- package/tools/tableEdit.d.ts +105 -0
- package/tools/tableEdit.mjs +3 -3
- package/tools/unlink.d.ts +24 -0
- package/tools/utils.d.ts +57 -0
- package/tools/utils.mjs +1 -1
- package/tools/viewHtml.d.ts +31 -0
- package/utils/browser-detection.d.ts +11 -0
- package/utils/controlled-value.d.ts +12 -0
- package/utils/index.d.ts +370 -0
- 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"),
|
|
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
|
|
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
|
|
13
|
-
import { defaultStyle as
|
|
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
|
|
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
|
|
21
|
-
import { keys as
|
|
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:
|
|
24
|
-
constructor(
|
|
25
|
-
super(
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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,
|
|
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(
|
|
77
|
-
get: () => (this.htmlOnChange =
|
|
78
|
-
}), this.props.onChange.call(void 0,
|
|
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(
|
|
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(
|
|
143
|
+
componentDidUpdate(h) {
|
|
144
144
|
const { value: t } = this.props, e = this.view;
|
|
145
|
-
t === void 0 || !e || (ot(e, t,
|
|
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
|
|
154
|
-
if (
|
|
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 =
|
|
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:
|
|
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
|
|
168
|
-
|
|
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
|
|
173
|
-
(
|
|
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__ */
|
|
175
|
+
return /* @__PURE__ */ l.createElement(
|
|
176
176
|
"div",
|
|
177
177
|
{
|
|
178
|
-
ref: (
|
|
179
|
-
this._element =
|
|
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
|
-
|
|
186
|
-
t === "iframe" ? /* @__PURE__ */
|
|
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: (
|
|
193
|
-
this.iframe =
|
|
192
|
+
ref: (o) => {
|
|
193
|
+
this.iframe = o;
|
|
194
194
|
},
|
|
195
195
|
frameBorder: "0",
|
|
196
|
-
title:
|
|
196
|
+
title: m.toLanguageString(P.iframeTitle, nt[P.iframeTitle]),
|
|
197
197
|
style: p,
|
|
198
198
|
className: "k-iframe"
|
|
199
199
|
}
|
|
200
|
-
)) : /* @__PURE__ */
|
|
200
|
+
)) : /* @__PURE__ */ l.createElement("div", { style: p, className: "k-editor-content" }, /* @__PURE__ */ l.createElement(
|
|
201
201
|
"div",
|
|
202
202
|
{
|
|
203
|
-
ref: (
|
|
204
|
-
this._contentElement =
|
|
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,
|
|
214
|
-
this.showLicenseWatermark && /* @__PURE__ */
|
|
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
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
if (
|
|
223
|
-
const
|
|
224
|
-
|
|
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
|
|
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
|
|
237
|
+
new w({
|
|
238
238
|
filterTransaction: this.filterTransaction,
|
|
239
239
|
key: new _("onExecute-event-plugin")
|
|
240
240
|
}),
|
|
241
|
-
new
|
|
241
|
+
new w({
|
|
242
242
|
key: T,
|
|
243
243
|
state: {
|
|
244
244
|
init: () => ({ preserveWhitespace: e }),
|
|
245
|
-
apply: (
|
|
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
|
-
...
|
|
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:
|
|
262
|
-
if (
|
|
263
|
-
const
|
|
264
|
-
!
|
|
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 !
|
|
266
|
+
return !n;
|
|
267
267
|
},
|
|
268
268
|
"Alt-F10": () => {
|
|
269
|
-
var
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
274
|
-
return
|
|
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:
|
|
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
|
-
}),
|
|
281
|
-
state:
|
|
282
|
-
plugins: [...s, S(c), S(
|
|
283
|
-
doc:
|
|
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: (
|
|
293
|
-
let
|
|
294
|
-
return
|
|
295
|
-
|
|
296
|
-
}),
|
|
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
|
-
},
|
|
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:
|
|
300
|
+
view: d
|
|
301
301
|
});
|
|
302
302
|
}
|
|
303
303
|
};
|