@progress/kendo-react-editor 16.2.0-develop.9 → 16.2.1-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/EULA.pdf +0 -0
- package/EULA.rtf +2730 -0
- package/EULA.txt +292 -0
- package/Editor.js +1 -1
- package/Editor.mjs +73 -72
- package/config/schema.d.ts +11 -1
- package/config/schema.js +8 -0
- package/config/schema.mjs +62 -0
- package/dialogs/insertLink.js +1 -1
- package/dialogs/insertLink.mjs +32 -31
- package/dist/cdn/js/kendo-react-editor.js +1 -1
- package/index.d.mts +3 -2
- package/index.d.ts +3 -2
- package/index.js +1 -1
- package/index.mjs +23 -22
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +13 -18
- package/utils/controlled-value.js +1 -1
- package/utils/controlled-value.mjs +14 -6
- package/utils/index.d.ts +9 -4
- package/utils/index.js +1 -1
- package/utils/index.mjs +112 -108
package/Editor.mjs
CHANGED
|
@@ -8,30 +8,31 @@
|
|
|
8
8
|
import * as t from "react";
|
|
9
9
|
import c from "prop-types";
|
|
10
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
|
|
12
|
-
import { Plugin as W, PluginKey as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
11
|
+
import { validatePackage as Ce, getLicenseMessage as Se, useWebMcpRegister as Le, classNames as Ne, WatermarkOverlay as Ae } from "@progress/kendo-react-common";
|
|
12
|
+
import { Plugin as W, PluginKey as V, spacesFix as Be, caretColor as Pe, history as De, dropCursor as Ie, gapCursor as Te, tableEditing as We, cspFix as xe, Schema as He, nodes as Me, EditorState as _e, keymap as j, baseKeymap as Fe, EditorView as Oe, getMark as ze } from "@progress/kendo-editor-common";
|
|
13
|
+
import { sanitizeLinkNode as Ve, marks as je } from "./config/schema.mjs";
|
|
14
|
+
import { defaultStyle as qe, tablesStyles as Ke, rtlStyles as $e } from "./config/defaultStyles.mjs";
|
|
15
|
+
import { EditorToolsSettings as Ge } from "./config/toolsSettings.mjs";
|
|
16
|
+
import { EditorDialogs as Ue } from "./dialogs/index.mjs";
|
|
16
17
|
import { EditorUtils as x } from "./utils/index.mjs";
|
|
17
18
|
import { editorPropsKey as q } from "./utils/props-key.mjs";
|
|
18
|
-
import { updateEditorValue as
|
|
19
|
+
import { updateEditorValue as Je } from "./utils/controlled-value.mjs";
|
|
19
20
|
import { packageMetadata as K } from "./package-metadata.mjs";
|
|
20
|
-
import { keys as b, messages as
|
|
21
|
-
import { useLocalization as
|
|
22
|
-
const { link: $, bold:
|
|
21
|
+
import { keys as b, messages as B } from "./messages/index.mjs";
|
|
22
|
+
import { useLocalization as Qe } from "@progress/kendo-react-intl";
|
|
23
|
+
const { link: $, bold: Xe, italic: Ye, underline: Ze } = Ge, G = t.forwardRef((d, U) => {
|
|
23
24
|
const { tools: J = [], defaultEditMode: Q = "iframe", preserveWhitespace: X = "full", style: k, className: Y } = d, [Z, E] = t.useState({
|
|
24
25
|
view: void 0,
|
|
25
26
|
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),
|
|
27
|
-
|
|
27
|
+
}), 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), o = t.useRef(d);
|
|
28
|
+
o.current = d;
|
|
28
29
|
const ee = t.useCallback((e) => {
|
|
29
30
|
P.current = e;
|
|
30
31
|
}, []), te = t.useCallback((e) => {
|
|
31
32
|
H.current = e;
|
|
32
33
|
}, []), re = t.useCallback((e) => {
|
|
33
34
|
f.current = e;
|
|
34
|
-
}, []), [ne] = t.useState(() => !Ce(K, { component: "Editor" })), [
|
|
35
|
+
}, []), [ne] = t.useState(() => !Ce(K, { component: "Editor" })), [oe] = t.useState(() => Se(K)), C = Qe(), S = t.useRef(null);
|
|
35
36
|
t.useImperativeHandle(
|
|
36
37
|
S,
|
|
37
38
|
() => ({
|
|
@@ -45,34 +46,34 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
45
46
|
return i.current;
|
|
46
47
|
},
|
|
47
48
|
get value() {
|
|
48
|
-
return v.current !== null ? v.current.doc :
|
|
49
|
+
return v.current !== null ? v.current.doc : o.current.value !== void 0 ? o.current.value : i.current ? i.current.state.doc : o.current.defaultContent || "";
|
|
49
50
|
},
|
|
50
51
|
get props() {
|
|
51
|
-
return
|
|
52
|
+
return o.current;
|
|
52
53
|
},
|
|
53
54
|
focus: () => {
|
|
54
55
|
i.current && i.current.focus();
|
|
55
56
|
}
|
|
56
57
|
})
|
|
57
58
|
), t.useImperativeHandle(U, () => S.current), Le("editor", S, d, d.webMcp);
|
|
58
|
-
const p = () => S.current,
|
|
59
|
+
const p = () => S.current, ae = t.useRef((e, r) => {
|
|
59
60
|
var s, g;
|
|
60
61
|
const n = { target: p(), transaction: e, state: r };
|
|
61
|
-
return ((g = (s =
|
|
62
|
+
return ((g = (s = o.current).onExecute) == null ? void 0 : g.call(s, n)) !== !1;
|
|
62
63
|
}).current, ce = t.useRef((e) => {
|
|
63
|
-
if (
|
|
64
|
+
if (o.current.onPasteHtml && w.current) {
|
|
64
65
|
const r = {
|
|
65
66
|
target: p(),
|
|
66
67
|
pastedHtml: e,
|
|
67
68
|
nativeEvent: w.current
|
|
68
|
-
}, n =
|
|
69
|
+
}, n = o.current.onPasteHtml(r);
|
|
69
70
|
if (w.current = void 0, typeof n == "string")
|
|
70
71
|
return n;
|
|
71
72
|
}
|
|
72
73
|
return e;
|
|
73
74
|
}).current, se = t.useRef((e) => {
|
|
74
75
|
const r = e.docChanged;
|
|
75
|
-
if (
|
|
76
|
+
if (o.current.onChange && r) {
|
|
76
77
|
v.current = e;
|
|
77
78
|
const s = e.doc, g = e.doc.type.schema, y = {
|
|
78
79
|
target: p(),
|
|
@@ -83,58 +84,58 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
83
84
|
};
|
|
84
85
|
Object.defineProperty(y, "html", {
|
|
85
86
|
get: () => (R.current = x.getHtml({ doc: s, schema: g }), R.current)
|
|
86
|
-
}),
|
|
87
|
+
}), o.current.onChange(y);
|
|
87
88
|
}
|
|
88
89
|
const n = i.current;
|
|
89
|
-
n && (
|
|
90
|
+
n && (o.current.value === void 0 || !r) && n.updateState(n.state.apply(e));
|
|
90
91
|
}).current, ie = t.useRef((e, r) => {
|
|
91
|
-
if (
|
|
92
|
+
if (o.current.onFocus) {
|
|
92
93
|
const n = {
|
|
93
94
|
target: p(),
|
|
94
95
|
nativeEvent: r
|
|
95
96
|
};
|
|
96
|
-
|
|
97
|
+
o.current.onFocus(n);
|
|
97
98
|
}
|
|
98
99
|
return !1;
|
|
99
100
|
}).current, ue = t.useRef((e, r) => {
|
|
100
|
-
if (
|
|
101
|
+
if (o.current.onBlur) {
|
|
101
102
|
const n = {
|
|
102
103
|
target: p(),
|
|
103
104
|
nativeEvent: r
|
|
104
105
|
};
|
|
105
|
-
|
|
106
|
+
o.current.onBlur(n);
|
|
106
107
|
}
|
|
107
108
|
return !1;
|
|
108
|
-
}).current, le = t.useRef((e, r) => (
|
|
109
|
-
if (
|
|
109
|
+
}).current, le = t.useRef((e, r) => (o.current.onPasteHtml && (w.current = r), !1)).current, de = t.useRef((e) => {
|
|
110
|
+
if (o.current.onIFrameInit) {
|
|
110
111
|
const r = {
|
|
111
112
|
target: p(),
|
|
112
113
|
iframe: e
|
|
113
114
|
};
|
|
114
|
-
|
|
115
|
+
o.current.onIFrameInit(r);
|
|
115
116
|
}
|
|
116
117
|
return !1;
|
|
117
118
|
}).current, fe = t.useRef((e, r) => {
|
|
118
119
|
E((n) => ({ ...n, view: e }));
|
|
119
120
|
}).current;
|
|
120
121
|
t.useEffect(() => {
|
|
121
|
-
var
|
|
122
|
+
var z;
|
|
122
123
|
const e = H.current, r = e == null ? void 0 : e.contentWindow;
|
|
123
124
|
if (r) {
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
126
|
-
const l =
|
|
127
|
-
l.setAttribute("charset", "utf-8"),
|
|
125
|
+
const a = r.document;
|
|
126
|
+
if (!a.head.querySelector("meta[charset]")) {
|
|
127
|
+
const l = a.createElement("meta");
|
|
128
|
+
l.setAttribute("charset", "utf-8"), a.head.appendChild(l);
|
|
128
129
|
}
|
|
129
|
-
const u =
|
|
130
|
-
u ? (u.textContent = "", f.current = u) : (f.current =
|
|
130
|
+
const u = a.body.querySelector(".k-content");
|
|
131
|
+
u ? (u.textContent = "", f.current = u) : (f.current = a.createElement("div"), a.body.appendChild(f.current), f.current.classList.add("k-content")), f.current.setAttribute("role", "textbox"), f.current.setAttribute(
|
|
131
132
|
"aria-label",
|
|
132
|
-
|
|
133
|
-
),
|
|
133
|
+
o.current.ariaLabel || C.toLanguageString(b.contentAreaLabel, B[b.contentAreaLabel])
|
|
134
|
+
), o.current.ariaLabelledBy && f.current.setAttribute("aria-labelledby", o.current.ariaLabelledBy), o.current.ariaDescribedBy && f.current.setAttribute("aria-describedby", o.current.ariaDescribedBy), e && o.current.onIFrameInit ? de(e) : a.head.querySelector("style") || [qe, Ke, o.current.dir === "rtl" ? $e : void 0].forEach(
|
|
134
135
|
(l) => {
|
|
135
136
|
if (l) {
|
|
136
|
-
const m =
|
|
137
|
-
m.appendChild(
|
|
137
|
+
const m = a.createElement("style");
|
|
138
|
+
m.appendChild(a.createTextNode(l)), a.head.appendChild(m);
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
);
|
|
@@ -142,24 +143,24 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
142
143
|
const n = f.current;
|
|
143
144
|
if (!n)
|
|
144
145
|
return;
|
|
145
|
-
const s = (
|
|
146
|
+
const s = (z = o.current.preserveWhitespace) != null ? z : "full", g = [
|
|
146
147
|
// https://prosemirror.net/docs/ref/#state.PluginSpec
|
|
147
148
|
new W({
|
|
148
149
|
view: (() => ({ update: fe })),
|
|
149
|
-
key: new
|
|
150
|
+
key: new V("toolbar-tools-update-plugin")
|
|
150
151
|
}),
|
|
151
152
|
new W({
|
|
152
|
-
filterTransaction:
|
|
153
|
-
key: new
|
|
153
|
+
filterTransaction: ae,
|
|
154
|
+
key: new V("onExecute-event-plugin")
|
|
154
155
|
}),
|
|
155
156
|
new W({
|
|
156
157
|
key: q,
|
|
157
158
|
state: {
|
|
158
159
|
init: () => ({ preserveWhitespace: s }),
|
|
159
|
-
apply: (
|
|
160
|
+
apply: (a, u) => u
|
|
160
161
|
}
|
|
161
162
|
}),
|
|
162
|
-
|
|
163
|
+
Be(),
|
|
163
164
|
Pe(),
|
|
164
165
|
De(),
|
|
165
166
|
Ie(),
|
|
@@ -169,31 +170,31 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
169
170
|
], y = {
|
|
170
171
|
...x.getShortcuts({
|
|
171
172
|
types: { listItem: "list_item", hardBreak: "hard_break" },
|
|
172
|
-
toolsSettings: { bold:
|
|
173
|
+
toolsSettings: { bold: Xe, italic: Ye, underline: Ze }
|
|
173
174
|
}),
|
|
174
175
|
"Mod-k": () => {
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const u =
|
|
176
|
+
const a = i.current;
|
|
177
|
+
if (a) {
|
|
178
|
+
const u = a.state, l = u.selection.empty, m = ze(u, u.schema.marks[$.mark]);
|
|
178
179
|
l && !m || E((h) => h.linkDialog ? h : { ...h, linkDialog: !0 });
|
|
179
180
|
}
|
|
180
181
|
return !0;
|
|
181
182
|
},
|
|
182
183
|
"Alt-F10": () => {
|
|
183
184
|
var u;
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
const l =
|
|
185
|
+
const a = (u = P.current) == null ? void 0 : u.querySelector(".k-toolbar");
|
|
186
|
+
if (a) {
|
|
187
|
+
const l = a.querySelector(Re.join(","));
|
|
187
188
|
if (l)
|
|
188
189
|
return l.focus(), !0;
|
|
189
190
|
}
|
|
190
191
|
return !1;
|
|
191
192
|
}
|
|
192
|
-
}, { defaultContent: ve = "", value:
|
|
193
|
+
}, { defaultContent: ve = "", value: N, onMount: T } = o.current, ye = N && typeof N != "string" ? Ve(N) : x.createDocument(new He({ nodes: Me, marks: je }), N || ve, {
|
|
193
194
|
preserveWhitespace: s
|
|
194
195
|
}), F = {
|
|
195
|
-
state:
|
|
196
|
-
plugins: [...g,
|
|
196
|
+
state: _e.create({
|
|
197
|
+
plugins: [...g, j(y), j(Fe)],
|
|
197
198
|
doc: ye
|
|
198
199
|
}),
|
|
199
200
|
transformPastedHTML: ce,
|
|
@@ -203,20 +204,20 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
203
204
|
blur: ue,
|
|
204
205
|
paste: le
|
|
205
206
|
},
|
|
206
|
-
handleDrop: (
|
|
207
|
-
let
|
|
207
|
+
handleDrop: (a, u, l, m) => {
|
|
208
|
+
let A = !1;
|
|
208
209
|
return l.content.nodesBetween(0, l.content.size, (h) => {
|
|
209
|
-
|
|
210
|
-
}),
|
|
210
|
+
A = A || h.type.name === "table_caption_external";
|
|
211
|
+
}), A;
|
|
211
212
|
}
|
|
212
|
-
}, he = { plugins: g, shortcuts: y, target: p(), viewProps: F, dom: n }, O = (T == null ? void 0 : T(he)) || new
|
|
213
|
-
return i.current = O, E((
|
|
213
|
+
}, he = { plugins: g, shortcuts: y, target: p(), viewProps: F, dom: n }, O = (T == null ? void 0 : T(he)) || new Oe({ mount: n }, F);
|
|
214
|
+
return i.current = O, E((a) => ({ ...a, view: O })), () => {
|
|
214
215
|
var u, l;
|
|
215
216
|
i.current && i.current.destroy(), i.current = void 0;
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
217
|
+
const a = e == null ? void 0 : e.contentWindow;
|
|
218
|
+
if (a != null && a.document) {
|
|
218
219
|
(l = (u = f.current) == null ? void 0 : u.parentNode) == null || l.removeChild(f.current);
|
|
219
|
-
const m =
|
|
220
|
+
const m = a.document.head;
|
|
220
221
|
for (; m != null && m.firstChild; )
|
|
221
222
|
m.removeChild(m.firstChild);
|
|
222
223
|
}
|
|
@@ -224,12 +225,12 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
224
225
|
}, []);
|
|
225
226
|
const D = t.useRef(d.value);
|
|
226
227
|
if (t.useEffect(() => {
|
|
227
|
-
const { value: e } =
|
|
228
|
+
const { value: e } = o.current, r = i.current;
|
|
228
229
|
if (e === void 0 || !r) {
|
|
229
230
|
D.current = e;
|
|
230
231
|
return;
|
|
231
232
|
}
|
|
232
|
-
|
|
233
|
+
Je(r, e, D.current, v.current, R.current), v.current = null, R.current = null, D.current = e;
|
|
233
234
|
}), i.current) {
|
|
234
235
|
const e = q.getState(i.current.state);
|
|
235
236
|
e.preserveWhitespace = X;
|
|
@@ -259,16 +260,16 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
259
260
|
(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
261
|
), be = C.toLanguageString(
|
|
261
262
|
b.toolbarAriaLabel,
|
|
262
|
-
|
|
263
|
+
B[b.toolbarAriaLabel]
|
|
263
264
|
), pe = C.toLanguageString(
|
|
264
265
|
b.contentAreaLabel,
|
|
265
|
-
|
|
266
|
+
B[b.contentAreaLabel]
|
|
266
267
|
);
|
|
267
268
|
return /* @__PURE__ */ t.createElement(
|
|
268
269
|
"div",
|
|
269
270
|
{
|
|
270
271
|
ref: ee,
|
|
271
|
-
className:
|
|
272
|
+
className: Ne("k-editor", Y, { "k-editor-resizable": d.resizable }),
|
|
272
273
|
dir: d.dir,
|
|
273
274
|
style: k
|
|
274
275
|
},
|
|
@@ -286,7 +287,7 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
286
287
|
{
|
|
287
288
|
ref: te,
|
|
288
289
|
frameBorder: "0",
|
|
289
|
-
title: C.toLanguageString(b.iframeTitle,
|
|
290
|
+
title: C.toLanguageString(b.iframeTitle, B[b.iframeTitle]),
|
|
290
291
|
style: L,
|
|
291
292
|
className: "k-iframe"
|
|
292
293
|
}
|
|
@@ -303,8 +304,8 @@ const { link: $, bold: Qe, italic: Xe, underline: Ye } = $e, G = t.forwardRef((d
|
|
|
303
304
|
suppressContentEditableWarning: !0
|
|
304
305
|
}
|
|
305
306
|
),
|
|
306
|
-
ge(
|
|
307
|
-
ne && /* @__PURE__ */ t.createElement(
|
|
307
|
+
ge(Ue.InsertLinkDialog, $, "linkDialog"),
|
|
308
|
+
ne && /* @__PURE__ */ t.createElement(Ae, { message: oe })
|
|
308
309
|
);
|
|
309
310
|
});
|
|
310
311
|
G.propTypes = {
|
package/config/schema.d.ts
CHANGED
|
@@ -5,4 +5,14 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import { MarkSpec, Node, Schema, parseContent as parseContentCommon } from '@progress/kendo-editor-common';
|
|
9
|
+
export { nodes } from '@progress/kendo-editor-common';
|
|
10
|
+
declare const marks: {
|
|
11
|
+
link: MarkSpec;
|
|
12
|
+
};
|
|
13
|
+
/** @hidden */
|
|
14
|
+
export declare const sanitizeLinkSchema: (schema: Schema) => Schema;
|
|
15
|
+
export declare const parseContent: typeof parseContentCommon;
|
|
16
|
+
/** @hidden */
|
|
17
|
+
export declare const sanitizeLinkNode: (node: Node) => Node;
|
|
18
|
+
export { marks };
|
package/config/schema.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@progress/kendo-editor-common"),k=require("@progress/kendo-react-common"),u=t=>{const r=(t.parseDOM||[]).map(i=>({...i,getAttrs:c=>{const s=typeof i.getAttrs=="function"?i.getAttrs(c):{};return s&&typeof s=="object"&&"href"in s&&(s.href=k.sanitizeUrl(s.href)||null),s}})),n=t.toDOM;return{...t,parseDOM:r,toDOM:typeof n=="function"?(i,c)=>{var s;return n({...i,attrs:{...i.attrs,href:k.sanitizeUrl((s=i.attrs)==null?void 0:s.href)||null}},c)}:n}},l={...a.marks,link:u(a.marks.link)},o=new WeakMap,p=new WeakMap,m=t=>{const r=o.get(t);if(r)return r;const n=t.spec.marks.get("link");if(!n)return o.set(t,t),t;const e=new a.Schema({...t.spec,marks:t.spec.marks.update("link",u(n))});return o.set(t,e),o.set(e,e),e},f=t=>{const r=t.marks.map(e=>e.type.name==="link"?e.type.create({...e.attrs,href:k.sanitizeUrl(e.attrs.href)||null}):e);if(t.isText)return t.mark(r);const n=[];return t.forEach(e=>n.push(f(e))),t.copy(a.Fragment.fromArray(n)).mark(r)},h=(t,r,n)=>f(a.parseContent(t,r,n)),d=t=>{const r=p.get(t);if(r)return r;const n=m(t.type.schema),e=f(n===t.type.schema?t:n.nodeFromJSON(t.toJSON()));return p.set(t,e),p.set(e,e),e};Object.defineProperty(exports,"nodes",{enumerable:!0,get:()=>a.nodes});exports.marks=l;exports.parseContent=h;exports.sanitizeLinkNode=d;exports.sanitizeLinkSchema=m;
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { marks as k, parseContent as h, Fragment as u, Schema as l } from "@progress/kendo-editor-common";
|
|
9
|
+
import { nodes as d } from "@progress/kendo-editor-common";
|
|
10
|
+
import { sanitizeUrl as p } from "@progress/kendo-react-common";
|
|
11
|
+
const m = (t) => {
|
|
12
|
+
const r = (t.parseDOM || []).map((a) => ({
|
|
13
|
+
...a,
|
|
14
|
+
getAttrs: (i) => {
|
|
15
|
+
const n = typeof a.getAttrs == "function" ? a.getAttrs(i) : {};
|
|
16
|
+
return n && typeof n == "object" && "href" in n && (n.href = p(n.href) || null), n;
|
|
17
|
+
}
|
|
18
|
+
})), s = t.toDOM;
|
|
19
|
+
return { ...t, parseDOM: r, toDOM: typeof s == "function" ? (a, i) => {
|
|
20
|
+
var n;
|
|
21
|
+
return s(
|
|
22
|
+
{
|
|
23
|
+
...a,
|
|
24
|
+
attrs: { ...a.attrs, href: p((n = a.attrs) == null ? void 0 : n.href) || null }
|
|
25
|
+
},
|
|
26
|
+
i
|
|
27
|
+
);
|
|
28
|
+
} : s };
|
|
29
|
+
}, g = { ...k, link: m(k.link) }, o = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), M = (t) => {
|
|
30
|
+
const r = o.get(t);
|
|
31
|
+
if (r)
|
|
32
|
+
return r;
|
|
33
|
+
const s = t.spec.marks.get("link");
|
|
34
|
+
if (!s)
|
|
35
|
+
return o.set(t, t), t;
|
|
36
|
+
const e = new l({
|
|
37
|
+
...t.spec,
|
|
38
|
+
marks: t.spec.marks.update("link", m(s))
|
|
39
|
+
});
|
|
40
|
+
return o.set(t, e), o.set(e, e), e;
|
|
41
|
+
}, f = (t) => {
|
|
42
|
+
const r = t.marks.map(
|
|
43
|
+
(e) => e.type.name === "link" ? e.type.create({ ...e.attrs, href: p(e.attrs.href) || null }) : e
|
|
44
|
+
);
|
|
45
|
+
if (t.isText)
|
|
46
|
+
return t.mark(r);
|
|
47
|
+
const s = [];
|
|
48
|
+
return t.forEach((e) => s.push(f(e))), t.copy(u.fromArray(s)).mark(r);
|
|
49
|
+
}, O = (t, r, s) => f(h(t, r, s)), S = (t) => {
|
|
50
|
+
const r = c.get(t);
|
|
51
|
+
if (r)
|
|
52
|
+
return r;
|
|
53
|
+
const s = M(t.type.schema), e = f(s === t.type.schema ? t : s.nodeFromJSON(t.toJSON()));
|
|
54
|
+
return c.set(t, e), c.set(e, e), e;
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
g as marks,
|
|
58
|
+
d as nodes,
|
|
59
|
+
O as parseContent,
|
|
60
|
+
S as sanitizeLinkNode,
|
|
61
|
+
M as sanitizeLinkSchema
|
|
62
|
+
};
|
package/dialogs/insertLink.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 S=require("react"),y=require("@progress/kendo-react-dialogs"),C=require("@progress/kendo-react-buttons"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),y=require("@progress/kendo-react-dialogs"),C=require("@progress/kendo-react-buttons"),u=require("@progress/kendo-react-inputs"),c=require("@progress/kendo-react-form"),x=require("@progress/kendo-react-common"),w=require("@progress/kendo-editor-common"),L=require("@progress/kendo-react-intl"),o=require("../messages/index.js");function I(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>s[n]})}}return t.default=s,Object.freeze(t)}const e=I(S);let F=class extends e.Component{constructor(){super(...arguments),this.href=null,this.title=null,this.target=null,this.onClose=()=>{this.props.view.focus(),this.props.onClose()},this.onInsert=()=>{const t=this.props.view,n=this.props.settings.mark,m={href:(this.href?x.sanitizeUrl(this.href.value):void 0)||void 0,title:this.title?this.title.value:void 0,target:this.target&&this.target.element&&this.target.element.checked?"_blank":void 0};w.applyLink({mark:n,attrs:m},this.props.settings.commandName)(t.state,t.dispatch),this.onClose()}}render(){const{view:t,settings:n,dir:r,render:m}=this.props,l=L.provideLocalizationService(this),{insertHyperlinkDialogTitle:d,insertHyperlinkAddress:g,insertHyperlinkTitle:k,insertHyperlinkNewWindow:h,insertHyperlinkCancel:p,insertHyperlinkInsert:f}=n.messages,a=t?w.getMark(t.state,t.state.schema.marks[n.mark]):!1,v=e.createElement(c.Form,{render:()=>e.createElement(c.FormElement,{horizontal:!0},e.createElement(c.FieldWrapper,null,e.createElement("label",{htmlFor:"k-editor-link-url",className:"k-form-label"},l.toLanguageString(g,o.messages[g])),e.createElement("div",{className:"k-form-field-wrap"},e.createElement(u.Input,{type:"text",id:"k-editor-link-url",ref:i=>{this.href=i&&i.element},defaultValue:a&&a.attrs.href||void 0,autoFocus:!0}))),e.createElement(c.FieldWrapper,null,e.createElement("label",{htmlFor:"k-editor-link-text",className:"k-form-label"},l.toLanguageString(k,o.messages[k])),e.createElement("div",{className:"k-form-field-wrap"},e.createElement(u.Input,{type:"text",id:"k-editor-link-text",ref:i=>{this.title=i&&i.element},defaultValue:a&&a.attrs.title||void 0}))),n.linkTarget!==!1&&e.createElement(c.FieldWrapper,null,e.createElement("label",{htmlFor:"k-editor-link-target",className:"k-checkbox-label"},e.createElement(u.Checkbox,{id:"k-editor-link-target",ref:i=>{this.target=i},defaultChecked:a&&!!a.attrs.target||void 0}),l.toLanguageString(h,o.messages[h]))))}),E=[e.createElement(C.Button,{onClick:this.onClose,dir:r,key:"cancel"},l.toLanguageString(p,o.messages[p])),e.createElement(C.Button,{onClick:this.onInsert,themeColor:"primary",dir:r,key:"insert"},l.toLanguageString(f,o.messages[f]))],b=e.createElement(y.Window,{initialWidth:450,initialHeight:250,className:"k-editor-window",title:l.toLanguageString(d,o.messages[d]),onClose:this.onClose,style:r==="rtl"?{textAlign:"right"}:void 0,modal:!0,minimizeButton:()=>null,maximizeButton:()=>null,resizable:!1},v,e.createElement(y.WindowActionsBar,null,...E));return m?m(b,{content:v,actionButtons:E}):b}};L.registerForLocalization(F);exports.InsertLinkDialog=F;
|
package/dialogs/insertLink.mjs
CHANGED
|
@@ -7,42 +7,43 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as e from "react";
|
|
9
9
|
import { Window as C, WindowActionsBar as w } from "@progress/kendo-react-dialogs";
|
|
10
|
-
import { Button as
|
|
10
|
+
import { Button as E } from "@progress/kendo-react-buttons";
|
|
11
11
|
import { Input as y, Checkbox as L } from "@progress/kendo-react-inputs";
|
|
12
|
-
import { Form as b, FormElement as x, FieldWrapper as
|
|
12
|
+
import { Form as b, FormElement as x, FieldWrapper as m } from "@progress/kendo-react-form";
|
|
13
|
+
import { sanitizeUrl as z } from "@progress/kendo-react-common";
|
|
13
14
|
import { applyLink as F, getMark as N } from "@progress/kendo-editor-common";
|
|
14
|
-
import { provideLocalizationService as
|
|
15
|
-
import { messages as
|
|
16
|
-
let
|
|
15
|
+
import { provideLocalizationService as H, registerForLocalization as I } from "@progress/kendo-react-intl";
|
|
16
|
+
import { messages as l } from "../messages/index.mjs";
|
|
17
|
+
let S = class extends e.Component {
|
|
17
18
|
constructor() {
|
|
18
19
|
super(...arguments), this.href = null, this.title = null, this.target = null, this.onClose = () => {
|
|
19
20
|
this.props.view.focus(), this.props.onClose();
|
|
20
21
|
}, this.onInsert = () => {
|
|
21
|
-
const r = this.props.view,
|
|
22
|
-
href: this.href ? this.href.value : void 0,
|
|
22
|
+
const r = this.props.view, o = this.props.settings.mark, s = {
|
|
23
|
+
href: (this.href ? z(this.href.value) : void 0) || void 0,
|
|
23
24
|
title: this.title ? this.title.value : void 0,
|
|
24
25
|
target: this.target && this.target.element && this.target.element.checked ? "_blank" : void 0
|
|
25
26
|
};
|
|
26
|
-
F({ mark:
|
|
27
|
+
F({ mark: o, attrs: s }, this.props.settings.commandName)(r.state, r.dispatch), this.onClose();
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* @hidden
|
|
31
32
|
*/
|
|
32
33
|
render() {
|
|
33
|
-
const { view: r, settings:
|
|
34
|
+
const { view: r, settings: o, dir: a, render: s } = this.props, i = H(this), {
|
|
34
35
|
insertHyperlinkDialogTitle: c,
|
|
35
36
|
insertHyperlinkAddress: h,
|
|
36
|
-
insertHyperlinkTitle:
|
|
37
|
-
insertHyperlinkNewWindow:
|
|
37
|
+
insertHyperlinkTitle: d,
|
|
38
|
+
insertHyperlinkNewWindow: k,
|
|
38
39
|
insertHyperlinkCancel: g,
|
|
39
40
|
insertHyperlinkInsert: p
|
|
40
|
-
} =
|
|
41
|
+
} = o.messages, n = r ? N(r.state, r.state.schema.marks[o.mark]) : !1, u = /* @__PURE__ */ e.createElement(
|
|
41
42
|
b,
|
|
42
43
|
{
|
|
43
|
-
render: () => /* @__PURE__ */ e.createElement(x, { horizontal: !0 }, /* @__PURE__ */ e.createElement(
|
|
44
|
+
render: () => /* @__PURE__ */ e.createElement(x, { horizontal: !0 }, /* @__PURE__ */ e.createElement(m, null, /* @__PURE__ */ e.createElement("label", { htmlFor: "k-editor-link-url", className: "k-form-label" }, i.toLanguageString(
|
|
44
45
|
h,
|
|
45
|
-
|
|
46
|
+
l[h]
|
|
46
47
|
)), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
47
48
|
y,
|
|
48
49
|
{
|
|
@@ -51,12 +52,12 @@ let I = class extends e.Component {
|
|
|
51
52
|
ref: (t) => {
|
|
52
53
|
this.href = t && t.element;
|
|
53
54
|
},
|
|
54
|
-
defaultValue:
|
|
55
|
+
defaultValue: n && n.attrs.href || void 0,
|
|
55
56
|
autoFocus: !0
|
|
56
57
|
}
|
|
57
|
-
))), /* @__PURE__ */ e.createElement(
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
))), /* @__PURE__ */ e.createElement(m, null, /* @__PURE__ */ e.createElement("label", { htmlFor: "k-editor-link-text", className: "k-form-label" }, i.toLanguageString(
|
|
59
|
+
d,
|
|
60
|
+
l[d]
|
|
60
61
|
)), /* @__PURE__ */ e.createElement("div", { className: "k-form-field-wrap" }, /* @__PURE__ */ e.createElement(
|
|
61
62
|
y,
|
|
62
63
|
{
|
|
@@ -65,26 +66,26 @@ let I = class extends e.Component {
|
|
|
65
66
|
ref: (t) => {
|
|
66
67
|
this.title = t && t.element;
|
|
67
68
|
},
|
|
68
|
-
defaultValue:
|
|
69
|
+
defaultValue: n && n.attrs.title || void 0
|
|
69
70
|
}
|
|
70
|
-
))),
|
|
71
|
+
))), o.linkTarget !== !1 && /* @__PURE__ */ e.createElement(m, null, /* @__PURE__ */ e.createElement("label", { htmlFor: "k-editor-link-target", className: "k-checkbox-label" }, /* @__PURE__ */ e.createElement(
|
|
71
72
|
L,
|
|
72
73
|
{
|
|
73
74
|
id: "k-editor-link-target",
|
|
74
75
|
ref: (t) => {
|
|
75
76
|
this.target = t;
|
|
76
77
|
},
|
|
77
|
-
defaultChecked:
|
|
78
|
+
defaultChecked: n && !!n.attrs.target || void 0
|
|
78
79
|
}
|
|
79
80
|
), i.toLanguageString(
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
k,
|
|
82
|
+
l[k]
|
|
82
83
|
))))
|
|
83
84
|
}
|
|
84
85
|
), f = [
|
|
85
|
-
/* @__PURE__ */ e.createElement(
|
|
86
|
-
/* @__PURE__ */ e.createElement(
|
|
87
|
-
],
|
|
86
|
+
/* @__PURE__ */ e.createElement(E, { onClick: this.onClose, dir: a, key: "cancel" }, i.toLanguageString(g, l[g])),
|
|
87
|
+
/* @__PURE__ */ e.createElement(E, { onClick: this.onInsert, themeColor: "primary", dir: a, key: "insert" }, i.toLanguageString(p, l[p]))
|
|
88
|
+
], v = /* @__PURE__ */ e.createElement(
|
|
88
89
|
C,
|
|
89
90
|
{
|
|
90
91
|
initialWidth: 450,
|
|
@@ -92,10 +93,10 @@ let I = class extends e.Component {
|
|
|
92
93
|
className: "k-editor-window",
|
|
93
94
|
title: i.toLanguageString(
|
|
94
95
|
c,
|
|
95
|
-
|
|
96
|
+
l[c]
|
|
96
97
|
),
|
|
97
98
|
onClose: this.onClose,
|
|
98
|
-
style:
|
|
99
|
+
style: a === "rtl" ? { textAlign: "right" } : void 0,
|
|
99
100
|
modal: !0,
|
|
100
101
|
minimizeButton: () => null,
|
|
101
102
|
maximizeButton: () => null,
|
|
@@ -104,10 +105,10 @@ let I = class extends e.Component {
|
|
|
104
105
|
u,
|
|
105
106
|
/* @__PURE__ */ e.createElement(w, null, ...f)
|
|
106
107
|
);
|
|
107
|
-
return
|
|
108
|
+
return s ? s(v, { content: u, actionButtons: f }) : v;
|
|
108
109
|
}
|
|
109
110
|
};
|
|
110
|
-
|
|
111
|
+
I(S);
|
|
111
112
|
export {
|
|
112
|
-
|
|
113
|
+
S as InsertLinkDialog
|
|
113
114
|
};
|