@progress/kendo-react-editor 15.2.0-develop.5 → 15.2.0-develop.6
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 +15 -95
- package/Editor.js +1 -1
- package/Editor.mjs +299 -306
- package/EditorProps.d.ts +2 -2
- package/dist/cdn/js/kendo-react-editor.js +1 -1
- package/index.d.mts +3 -4
- package/index.d.ts +3 -4
- package/index.js +1 -1
- package/index.mjs +136 -138
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +12 -12
- package/EditorMcpWrapper.d.ts +0 -17
- package/EditorMcpWrapper.js +0 -8
- package/EditorMcpWrapper.mjs +0 -18
package/Editor.mjs
CHANGED
|
@@ -5,339 +5,332 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { validatePackage as
|
|
12
|
-
import { Plugin as
|
|
13
|
-
import { defaultStyle as
|
|
14
|
-
import { EditorToolsSettings as
|
|
15
|
-
import { EditorDialogs as
|
|
16
|
-
import { EditorUtils as
|
|
17
|
-
import { editorPropsKey as
|
|
18
|
-
import { updateEditorValue as
|
|
19
|
-
import { packageMetadata as
|
|
20
|
-
import { keys as
|
|
21
|
-
import {
|
|
22
|
-
const { link:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const e = {
|
|
56
|
-
target: this,
|
|
57
|
-
pastedHtml: t,
|
|
58
|
-
nativeEvent: this.pasteEvent
|
|
59
|
-
}, s = this.props.onPasteHtml.call(void 0, e);
|
|
60
|
-
if (this.pasteEvent = void 0, typeof s == "string")
|
|
61
|
-
return s;
|
|
62
|
-
}
|
|
63
|
-
return t;
|
|
64
|
-
}, this.dispatchTransaction = (t) => {
|
|
65
|
-
const e = t.docChanged;
|
|
66
|
-
if (this.props.onChange && e) {
|
|
67
|
-
this.trOnChange = t;
|
|
68
|
-
const s = t.doc, h = t.doc.type.schema, p = {
|
|
69
|
-
target: this,
|
|
70
|
-
value: s,
|
|
71
|
-
html: "",
|
|
72
|
-
transaction: t,
|
|
73
|
-
schema: h
|
|
74
|
-
};
|
|
75
|
-
Object.defineProperty(p, "html", {
|
|
76
|
-
get: () => (this.htmlOnChange = k.getHtml({ doc: s, schema: h }), this.htmlOnChange)
|
|
77
|
-
}), this.props.onChange.call(void 0, p);
|
|
78
|
-
}
|
|
79
|
-
this.view && (this.props.value === void 0 || !e) && this.view.updateState(this.view.state.apply(t));
|
|
80
|
-
}, this.onFocus = (t, e) => {
|
|
81
|
-
if (this.props.onFocus) {
|
|
82
|
-
const s = {
|
|
83
|
-
target: this,
|
|
84
|
-
nativeEvent: e
|
|
85
|
-
};
|
|
86
|
-
this.props.onFocus.call(void 0, s);
|
|
87
|
-
}
|
|
88
|
-
return !1;
|
|
89
|
-
}, this.onBlur = (t, e) => {
|
|
90
|
-
if (this.props.onBlur) {
|
|
91
|
-
const s = {
|
|
92
|
-
target: this,
|
|
93
|
-
nativeEvent: e
|
|
94
|
-
};
|
|
95
|
-
this.props.onBlur.call(void 0, s);
|
|
96
|
-
}
|
|
97
|
-
return !1;
|
|
98
|
-
}, this.onPaste = (t, e) => (this.props.onPasteHtml && (this.pasteEvent = e), !1), this.onIFrameInit = (t) => {
|
|
99
|
-
if (this.props.onIFrameInit) {
|
|
100
|
-
const e = {
|
|
101
|
-
target: this,
|
|
102
|
-
iframe: t
|
|
103
|
-
};
|
|
104
|
-
this.props.onIFrameInit.call(void 0, e);
|
|
8
|
+
import * as t from "react";
|
|
9
|
+
import c from "prop-types";
|
|
10
|
+
import { ButtonGroup as ke, Toolbar as Ee, toolbarButtons as Re, ToolbarSeparator as we } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { validatePackage as Ce, getLicenseMessage as Se, useWebMcpRegister as Le, classNames as Ae, WatermarkOverlay as Be } from "@progress/kendo-react-common";
|
|
12
|
+
import { Plugin as W, PluginKey as j, spacesFix as Ne, caretColor as Pe, history as De, dropCursor as Ie, gapCursor as Te, tableEditing as We, cspFix as xe, Schema as He, marks as Me, nodes as _e, EditorState as Fe, keymap as z, baseKeymap as Oe, EditorView as Ve, getMark as je } from "@progress/kendo-editor-common";
|
|
13
|
+
import { defaultStyle as ze, tablesStyles as qe, rtlStyles as Ke } from "./config/defaultStyles.mjs";
|
|
14
|
+
import { EditorToolsSettings as $e } from "./config/toolsSettings.mjs";
|
|
15
|
+
import { EditorDialogs as Ge } from "./dialogs/index.mjs";
|
|
16
|
+
import { EditorUtils as x } from "./utils/index.mjs";
|
|
17
|
+
import { editorPropsKey as q } from "./utils/props-key.mjs";
|
|
18
|
+
import { updateEditorValue as Ue } from "./utils/controlled-value.mjs";
|
|
19
|
+
import { packageMetadata as K } from "./package-metadata.mjs";
|
|
20
|
+
import { keys as b, messages as N } from "./messages/index.mjs";
|
|
21
|
+
import { useLocalization as Je } from "@progress/kendo-react-intl";
|
|
22
|
+
const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d, U) => {
|
|
23
|
+
const { tools: J = [], defaultEditMode: Q = "iframe", preserveWhitespace: X = "full", style: k, className: Y } = d, [Z, E] = t.useState({
|
|
24
|
+
view: void 0,
|
|
25
|
+
linkDialog: !1
|
|
26
|
+
}), P = t.useRef(null), f = t.useRef(null), H = t.useRef(null), i = t.useRef(void 0), v = t.useRef(null), R = t.useRef(null), w = t.useRef(void 0), a = t.useRef(d);
|
|
27
|
+
a.current = d;
|
|
28
|
+
const ee = t.useCallback((e) => {
|
|
29
|
+
P.current = e;
|
|
30
|
+
}, []), te = t.useCallback((e) => {
|
|
31
|
+
H.current = e;
|
|
32
|
+
}, []), re = t.useCallback((e) => {
|
|
33
|
+
f.current = e;
|
|
34
|
+
}, []), [ne] = t.useState(() => !Ce(K, { component: "Editor" })), [ae] = t.useState(() => Se(K)), C = Je(), S = t.useRef(null);
|
|
35
|
+
t.useImperativeHandle(
|
|
36
|
+
S,
|
|
37
|
+
() => ({
|
|
38
|
+
get element() {
|
|
39
|
+
return P.current;
|
|
40
|
+
},
|
|
41
|
+
get contentElement() {
|
|
42
|
+
return f.current;
|
|
43
|
+
},
|
|
44
|
+
get view() {
|
|
45
|
+
return i.current;
|
|
46
|
+
},
|
|
47
|
+
get value() {
|
|
48
|
+
return v.current !== null ? v.current.doc : a.current.value !== void 0 ? a.current.value : i.current ? i.current.state.doc : a.current.defaultContent || "";
|
|
49
|
+
},
|
|
50
|
+
get props() {
|
|
51
|
+
return a.current;
|
|
52
|
+
},
|
|
53
|
+
focus: () => {
|
|
54
|
+
i.current && i.current.focus();
|
|
105
55
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Returns the content-editable DOM element of the Editor.
|
|
123
|
-
*/
|
|
124
|
-
get contentElement() {
|
|
125
|
-
return this._contentElement;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Returns the `view` object of the Editor.
|
|
129
|
-
*/
|
|
130
|
-
get view() {
|
|
131
|
-
return this._view;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* @hidden
|
|
135
|
-
*/
|
|
136
|
-
componentDidMount() {
|
|
137
|
-
this.initialize();
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @hidden
|
|
141
|
-
*/
|
|
142
|
-
componentDidUpdate(l) {
|
|
143
|
-
const { value: t } = this.props, e = this.view;
|
|
144
|
-
t === void 0 || !e || (ot(e, t, l.value, this.trOnChange, this.htmlOnChange), this.trOnChange = null, this.htmlOnChange = null);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* @hidden
|
|
148
|
-
*/
|
|
149
|
-
componentWillUnmount() {
|
|
150
|
-
var t;
|
|
151
|
-
this.view && this.view.destroy(), this._view = void 0;
|
|
152
|
-
const l = (t = this.iframe) == null ? void 0 : t.contentWindow;
|
|
153
|
-
if (l) {
|
|
154
|
-
this._contentElement && this._contentElement.parentNode && this._contentElement.parentNode.removeChild(this._contentElement);
|
|
155
|
-
const e = l.document.head;
|
|
156
|
-
for (; e && e.firstChild; )
|
|
157
|
-
e.removeChild(e.firstChild);
|
|
56
|
+
})
|
|
57
|
+
), t.useImperativeHandle(U, () => S.current), Le("editor", S, d, d.webMcp);
|
|
58
|
+
const p = () => S.current, oe = t.useRef((e, r) => {
|
|
59
|
+
var s, g;
|
|
60
|
+
const n = { target: p(), transaction: e, state: r };
|
|
61
|
+
return ((g = (s = a.current).onExecute) == null ? void 0 : g.call(s, n)) !== !1;
|
|
62
|
+
}).current, ce = t.useRef((e) => {
|
|
63
|
+
if (a.current.onPasteHtml && w.current) {
|
|
64
|
+
const r = {
|
|
65
|
+
target: p(),
|
|
66
|
+
pastedHtml: e,
|
|
67
|
+
nativeEvent: w.current
|
|
68
|
+
}, n = a.current.onPasteHtml(r);
|
|
69
|
+
if (w.current = void 0, typeof n == "string")
|
|
70
|
+
return n;
|
|
158
71
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
72
|
+
return e;
|
|
73
|
+
}).current, se = t.useRef((e) => {
|
|
74
|
+
const r = e.docChanged;
|
|
75
|
+
if (a.current.onChange && r) {
|
|
76
|
+
v.current = e;
|
|
77
|
+
const s = e.doc, g = e.doc.type.schema, y = {
|
|
78
|
+
target: p(),
|
|
79
|
+
value: s,
|
|
80
|
+
html: "",
|
|
81
|
+
transaction: e,
|
|
82
|
+
schema: g
|
|
83
|
+
};
|
|
84
|
+
Object.defineProperty(y, "html", {
|
|
85
|
+
get: () => (R.current = x.getHtml({ doc: s, schema: g }), R.current)
|
|
86
|
+
}), a.current.onChange(y);
|
|
168
87
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
role: "textbox",
|
|
213
|
-
"aria-labelledby": this.props.ariaLabelledBy,
|
|
214
|
-
"aria-describedby": this.props.ariaDescribedBy,
|
|
215
|
-
"aria-label": u,
|
|
216
|
-
suppressContentEditableWarning: !0
|
|
217
|
-
}
|
|
218
|
-
),
|
|
219
|
-
this.renderDialog(nt.InsertLinkDialog, P, "linkDialog"),
|
|
220
|
-
this.showLicenseWatermark && /* @__PURE__ */ c.createElement(H, { message: this.licenseMessage })
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
initialize() {
|
|
224
|
-
const l = this.iframe && this.iframe.contentWindow;
|
|
225
|
-
if (l) {
|
|
226
|
-
const n = l.document, r = n.createElement("meta");
|
|
227
|
-
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._contentElement.setAttribute("role", "textbox"), this.props.ariaLabelledBy && this._contentElement.setAttribute("aria-labelledby", this.props.ariaLabelledBy), this.props.ariaDescribedBy && this._contentElement.setAttribute("aria-describedby", this.props.ariaDescribedBy), this._contentElement.setAttribute(
|
|
88
|
+
const n = i.current;
|
|
89
|
+
n && (a.current.value === void 0 || !r) && n.updateState(n.state.apply(e));
|
|
90
|
+
}).current, ie = t.useRef((e, r) => {
|
|
91
|
+
if (a.current.onFocus) {
|
|
92
|
+
const n = {
|
|
93
|
+
target: p(),
|
|
94
|
+
nativeEvent: r
|
|
95
|
+
};
|
|
96
|
+
a.current.onFocus(n);
|
|
97
|
+
}
|
|
98
|
+
return !1;
|
|
99
|
+
}).current, ue = t.useRef((e, r) => {
|
|
100
|
+
if (a.current.onBlur) {
|
|
101
|
+
const n = {
|
|
102
|
+
target: p(),
|
|
103
|
+
nativeEvent: r
|
|
104
|
+
};
|
|
105
|
+
a.current.onBlur(n);
|
|
106
|
+
}
|
|
107
|
+
return !1;
|
|
108
|
+
}).current, le = t.useRef((e, r) => (a.current.onPasteHtml && (w.current = r), !1)).current, de = t.useRef((e) => {
|
|
109
|
+
if (a.current.onIFrameInit) {
|
|
110
|
+
const r = {
|
|
111
|
+
target: p(),
|
|
112
|
+
iframe: e
|
|
113
|
+
};
|
|
114
|
+
a.current.onIFrameInit(r);
|
|
115
|
+
}
|
|
116
|
+
return !1;
|
|
117
|
+
}).current, fe = t.useRef((e, r) => {
|
|
118
|
+
E((n) => ({ ...n, view: e }));
|
|
119
|
+
}).current;
|
|
120
|
+
t.useEffect(() => {
|
|
121
|
+
var V;
|
|
122
|
+
const e = H.current, r = e == null ? void 0 : e.contentWindow;
|
|
123
|
+
if (r) {
|
|
124
|
+
const o = r.document;
|
|
125
|
+
if (!o.head.querySelector("meta[charset]")) {
|
|
126
|
+
const l = o.createElement("meta");
|
|
127
|
+
l.setAttribute("charset", "utf-8"), o.head.appendChild(l);
|
|
128
|
+
}
|
|
129
|
+
const u = o.body.querySelector(".k-content");
|
|
130
|
+
u ? (u.textContent = "", f.current = u) : (f.current = o.createElement("div"), o.body.appendChild(f.current), f.current.classList.add("k-content")), f.current.setAttribute("role", "textbox"), f.current.setAttribute(
|
|
228
131
|
"aria-label",
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
v.appendChild(n.createTextNode(a)), n.head.appendChild(v);
|
|
132
|
+
a.current.ariaLabel || C.toLanguageString(b.contentAreaLabel, N[b.contentAreaLabel])
|
|
133
|
+
), a.current.ariaLabelledBy && f.current.setAttribute("aria-labelledby", a.current.ariaLabelledBy), a.current.ariaDescribedBy && f.current.setAttribute("aria-describedby", a.current.ariaDescribedBy), e && a.current.onIFrameInit ? de(e) : o.head.querySelector("style") || [ze, qe, a.current.dir === "rtl" ? Ke : void 0].forEach(
|
|
134
|
+
(l) => {
|
|
135
|
+
if (l) {
|
|
136
|
+
const m = o.createElement("style");
|
|
137
|
+
m.appendChild(o.createTextNode(l)), o.head.appendChild(m);
|
|
138
|
+
}
|
|
237
139
|
}
|
|
238
|
-
|
|
140
|
+
);
|
|
239
141
|
}
|
|
240
|
-
const
|
|
241
|
-
if (!
|
|
142
|
+
const n = f.current;
|
|
143
|
+
if (!n)
|
|
242
144
|
return;
|
|
243
|
-
const
|
|
145
|
+
const s = (V = a.current.preserveWhitespace) != null ? V : "full", g = [
|
|
244
146
|
// https://prosemirror.net/docs/ref/#state.PluginSpec
|
|
245
|
-
new
|
|
246
|
-
view: (() => ({ update:
|
|
247
|
-
key: new
|
|
147
|
+
new W({
|
|
148
|
+
view: (() => ({ update: fe })),
|
|
149
|
+
key: new j("toolbar-tools-update-plugin")
|
|
248
150
|
}),
|
|
249
|
-
new
|
|
250
|
-
filterTransaction:
|
|
251
|
-
key: new
|
|
151
|
+
new W({
|
|
152
|
+
filterTransaction: oe,
|
|
153
|
+
key: new j("onExecute-event-plugin")
|
|
252
154
|
}),
|
|
253
|
-
new
|
|
254
|
-
key:
|
|
155
|
+
new W({
|
|
156
|
+
key: q,
|
|
255
157
|
state: {
|
|
256
|
-
init: () => ({ preserveWhitespace:
|
|
257
|
-
apply: (
|
|
158
|
+
init: () => ({ preserveWhitespace: s }),
|
|
159
|
+
apply: (o, u) => u
|
|
258
160
|
}
|
|
259
161
|
}),
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
],
|
|
268
|
-
...
|
|
162
|
+
Ne(),
|
|
163
|
+
Pe(),
|
|
164
|
+
De(),
|
|
165
|
+
Ie(),
|
|
166
|
+
Te(),
|
|
167
|
+
We(),
|
|
168
|
+
xe()
|
|
169
|
+
], y = {
|
|
170
|
+
...x.getShortcuts({
|
|
269
171
|
types: { listItem: "list_item", hardBreak: "hard_break" },
|
|
270
|
-
toolsSettings: { bold:
|
|
172
|
+
toolsSettings: { bold: Qe, italic: Xe, underline: Ye }
|
|
271
173
|
}),
|
|
272
174
|
"Mod-k": () => {
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
275
|
-
const
|
|
276
|
-
|
|
175
|
+
const o = i.current;
|
|
176
|
+
if (o) {
|
|
177
|
+
const u = o.state, l = u.selection.empty, m = je(u, u.schema.marks[$.mark]);
|
|
178
|
+
l && !m || E((h) => h.linkDialog ? h : { ...h, linkDialog: !0 });
|
|
277
179
|
}
|
|
278
|
-
return !
|
|
180
|
+
return !0;
|
|
279
181
|
},
|
|
280
182
|
"Alt-F10": () => {
|
|
281
|
-
var
|
|
282
|
-
const
|
|
283
|
-
if (
|
|
284
|
-
const
|
|
285
|
-
if (
|
|
286
|
-
return
|
|
183
|
+
var u;
|
|
184
|
+
const o = (u = P.current) == null ? void 0 : u.querySelector(".k-toolbar");
|
|
185
|
+
if (o) {
|
|
186
|
+
const l = o.querySelector(Re.join(","));
|
|
187
|
+
if (l)
|
|
188
|
+
return l.focus(), !0;
|
|
287
189
|
}
|
|
288
190
|
return !1;
|
|
289
191
|
}
|
|
290
|
-
}, { defaultContent:
|
|
291
|
-
preserveWhitespace:
|
|
292
|
-
}),
|
|
293
|
-
state:
|
|
294
|
-
plugins: [...
|
|
295
|
-
doc:
|
|
192
|
+
}, { defaultContent: ve = "", value: A, onMount: T } = a.current, ye = A && typeof A != "string" ? A : x.createDocument(new He({ nodes: _e, marks: Me }), A || ve, {
|
|
193
|
+
preserveWhitespace: s
|
|
194
|
+
}), F = {
|
|
195
|
+
state: Fe.create({
|
|
196
|
+
plugins: [...g, z(y), z(Oe)],
|
|
197
|
+
doc: ye
|
|
296
198
|
}),
|
|
297
|
-
transformPastedHTML:
|
|
298
|
-
dispatchTransaction:
|
|
199
|
+
transformPastedHTML: ce,
|
|
200
|
+
dispatchTransaction: se,
|
|
299
201
|
handleDOMEvents: {
|
|
300
|
-
focus:
|
|
301
|
-
blur:
|
|
302
|
-
paste:
|
|
202
|
+
focus: ie,
|
|
203
|
+
blur: ue,
|
|
204
|
+
paste: le
|
|
303
205
|
},
|
|
304
|
-
handleDrop: (
|
|
305
|
-
let
|
|
306
|
-
return
|
|
307
|
-
|
|
308
|
-
}),
|
|
206
|
+
handleDrop: (o, u, l, m) => {
|
|
207
|
+
let B = !1;
|
|
208
|
+
return l.content.nodesBetween(0, l.content.size, (h) => {
|
|
209
|
+
B = B || h.type.name === "table_caption_external";
|
|
210
|
+
}), B;
|
|
309
211
|
}
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
212
|
+
}, he = { plugins: g, shortcuts: y, target: p(), viewProps: F, dom: n }, O = (T == null ? void 0 : T(he)) || new Ve({ mount: n }, F);
|
|
213
|
+
return i.current = O, E((o) => ({ ...o, view: O })), () => {
|
|
214
|
+
var u, l;
|
|
215
|
+
i.current && i.current.destroy(), i.current = void 0;
|
|
216
|
+
const o = e == null ? void 0 : e.contentWindow;
|
|
217
|
+
if (o != null && o.document) {
|
|
218
|
+
(l = (u = f.current) == null ? void 0 : u.parentNode) == null || l.removeChild(f.current);
|
|
219
|
+
const m = o.document.head;
|
|
220
|
+
for (; m != null && m.firstChild; )
|
|
221
|
+
m.removeChild(m.firstChild);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}, []);
|
|
225
|
+
const D = t.useRef(d.value);
|
|
226
|
+
if (t.useEffect(() => {
|
|
227
|
+
const { value: e } = a.current, r = i.current;
|
|
228
|
+
if (e === void 0 || !r) {
|
|
229
|
+
D.current = e;
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
Ue(r, e, D.current, v.current, R.current), v.current = null, R.current = null, D.current = e;
|
|
233
|
+
}), i.current) {
|
|
234
|
+
const e = q.getState(i.current.state);
|
|
235
|
+
e.preserveWhitespace = X;
|
|
314
236
|
}
|
|
237
|
+
let L = d.contentStyle;
|
|
238
|
+
L === void 0 && (k == null ? void 0 : k.height) === void 0 && (L = { height: "300px" });
|
|
239
|
+
const I = (e, r, n) => e.displayName || e.name || `tool-${r}-${n}`, me = (e, r) => e.map((n, s) => I(n, r, s)).join("-") || `group-${r}`, M = (e, r, n = !1) => {
|
|
240
|
+
const s = /* @__PURE__ */ t.createElement(
|
|
241
|
+
e,
|
|
242
|
+
{
|
|
243
|
+
view: i.current,
|
|
244
|
+
dir: d.dir,
|
|
245
|
+
key: r,
|
|
246
|
+
className: n ? "k-toolbar-button" : void 0
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
return s.type === we ? /* @__PURE__ */ t.createElement(e, { key: r }) : s;
|
|
250
|
+
}, ge = (e, r, n) => Z[n] && /* @__PURE__ */ t.createElement(
|
|
251
|
+
e,
|
|
252
|
+
{
|
|
253
|
+
view: i.current,
|
|
254
|
+
settings: r,
|
|
255
|
+
dir: d.dir,
|
|
256
|
+
onClose: () => E((s) => ({ ...s, [n]: !1 }))
|
|
257
|
+
}
|
|
258
|
+
), _ = J.map(
|
|
259
|
+
(e, r) => Array.isArray(e) ? /* @__PURE__ */ t.createElement(ke, { key: me(e, r), className: "k-toolbar-button-group" }, e.map((n, s) => M(n, I(n, r, s)))) : M(e, I(e, r, 0), !0)
|
|
260
|
+
), be = C.toLanguageString(
|
|
261
|
+
b.toolbarAriaLabel,
|
|
262
|
+
N[b.toolbarAriaLabel]
|
|
263
|
+
), pe = C.toLanguageString(
|
|
264
|
+
b.contentAreaLabel,
|
|
265
|
+
N[b.contentAreaLabel]
|
|
266
|
+
);
|
|
267
|
+
return /* @__PURE__ */ t.createElement(
|
|
268
|
+
"div",
|
|
269
|
+
{
|
|
270
|
+
ref: ee,
|
|
271
|
+
className: Ae("k-editor", Y, { "k-editor-resizable": d.resizable }),
|
|
272
|
+
dir: d.dir,
|
|
273
|
+
style: k
|
|
274
|
+
},
|
|
275
|
+
_.length > 0 && /* @__PURE__ */ t.createElement(
|
|
276
|
+
Ee,
|
|
277
|
+
{
|
|
278
|
+
className: "k-editor-toolbar",
|
|
279
|
+
keyboardNavigation: d.keyboardNavigation,
|
|
280
|
+
ariaLabel: be
|
|
281
|
+
},
|
|
282
|
+
_
|
|
283
|
+
),
|
|
284
|
+
Q === "iframe" ? /* @__PURE__ */ t.createElement("div", { className: "k-editor-content" }, /* @__PURE__ */ t.createElement(
|
|
285
|
+
"iframe",
|
|
286
|
+
{
|
|
287
|
+
ref: te,
|
|
288
|
+
frameBorder: "0",
|
|
289
|
+
title: C.toLanguageString(b.iframeTitle, N[b.iframeTitle]),
|
|
290
|
+
style: L,
|
|
291
|
+
className: "k-iframe"
|
|
292
|
+
}
|
|
293
|
+
)) : /* @__PURE__ */ t.createElement(
|
|
294
|
+
"div",
|
|
295
|
+
{
|
|
296
|
+
ref: re,
|
|
297
|
+
style: L,
|
|
298
|
+
className: "k-editor-content",
|
|
299
|
+
role: "textbox",
|
|
300
|
+
"aria-label": pe,
|
|
301
|
+
"aria-labelledby": d.ariaLabelledBy,
|
|
302
|
+
"aria-describedby": d.ariaDescribedBy,
|
|
303
|
+
suppressContentEditableWarning: !0
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
ge(Ge.InsertLinkDialog, $, "linkDialog"),
|
|
307
|
+
ne && /* @__PURE__ */ t.createElement(Be, { message: ae })
|
|
308
|
+
);
|
|
309
|
+
});
|
|
310
|
+
G.propTypes = {
|
|
311
|
+
defaultContent: c.string,
|
|
312
|
+
value: c.oneOfType([c.object, c.string]),
|
|
313
|
+
defaultEditMode: c.oneOf(["iframe", "div"]),
|
|
314
|
+
contentStyle: c.object,
|
|
315
|
+
dir: c.string,
|
|
316
|
+
className: c.string,
|
|
317
|
+
ariaDescribedBy: c.string,
|
|
318
|
+
ariaLabelledBy: c.string,
|
|
319
|
+
ariaLabel: c.string,
|
|
320
|
+
style: c.object,
|
|
321
|
+
tools: c.arrayOf(c.any),
|
|
322
|
+
keyboardNavigation: c.bool,
|
|
323
|
+
resizable: c.bool,
|
|
324
|
+
preserveWhitespace: c.oneOf([!0, !1, "full"]),
|
|
325
|
+
onMount: c.func,
|
|
326
|
+
onFocus: c.func,
|
|
327
|
+
onBlur: c.func,
|
|
328
|
+
onChange: c.func,
|
|
329
|
+
onPasteHtml: c.func,
|
|
330
|
+
onExecute: c.func,
|
|
331
|
+
onIFrameInit: c.func
|
|
315
332
|
};
|
|
316
|
-
|
|
317
|
-
defaultContent: i.string,
|
|
318
|
-
value: i.oneOfType([i.object, i.string]),
|
|
319
|
-
defaultEditMode: i.oneOf(["iframe", "div"]),
|
|
320
|
-
contentStyle: i.object,
|
|
321
|
-
dir: i.string,
|
|
322
|
-
className: i.string,
|
|
323
|
-
ariaDescribedBy: i.string,
|
|
324
|
-
ariaLabelledBy: i.string,
|
|
325
|
-
ariaLabel: i.string,
|
|
326
|
-
style: i.object,
|
|
327
|
-
tools: i.arrayOf(i.any),
|
|
328
|
-
keyboardNavigation: i.bool,
|
|
329
|
-
resizable: i.bool,
|
|
330
|
-
preserveWhitespace: i.oneOf([!0, !1, "full"]),
|
|
331
|
-
onMount: i.func,
|
|
332
|
-
onFocus: i.func,
|
|
333
|
-
onBlur: i.func,
|
|
334
|
-
onChange: i.func,
|
|
335
|
-
onPasteHtml: i.func,
|
|
336
|
-
onExecute: i.func,
|
|
337
|
-
onIFrameInit: i.func
|
|
338
|
-
};
|
|
339
|
-
let C = _;
|
|
340
|
-
rt(C);
|
|
333
|
+
G.displayName = "KendoReactEditor";
|
|
341
334
|
export {
|
|
342
|
-
|
|
335
|
+
G as Editor
|
|
343
336
|
};
|
package/EditorProps.d.ts
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { EditorState, Plugin, Transaction, EditorView, Schema, Node } from '@progress/kendo-editor-common';
|
|
9
9
|
import { EditorUtils } from './utils/index.js';
|
|
10
|
-
import {
|
|
10
|
+
import { EditorHandle } from './Editor.js';
|
|
11
11
|
import { WebMcpProps } from '@progress/kendo-react-common';
|
|
12
12
|
interface EditorEvent {
|
|
13
13
|
/**
|
|
14
14
|
* An event target.
|
|
15
15
|
*/
|
|
16
|
-
target:
|
|
16
|
+
target: EditorHandle;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Represents the object of the `onChange` Editor event.
|