@nice2dev/ui 1.3.9 → 1.3.10
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/CHANGELOG.md +37 -0
- package/dist/NiceColorPicker-BLwYNSXJ.cjs +1 -0
- package/dist/NiceColorPicker-DS59tNkP.js +552 -0
- package/dist/NiceDataGrid-CL2_7fS7.cjs +10 -0
- package/dist/NiceDataGrid-CpJrRN_H.js +2269 -0
- package/dist/NiceForm-BQj-K7p7.cjs +1 -0
- package/dist/NiceForm-HQ4h7hX_.js +5023 -0
- package/dist/NiceGantt-BygumlaY.cjs +1 -0
- package/dist/NiceGantt-DTC7OH-v.js +334 -0
- package/dist/NiceHtmlEditor-BtpuaLln.js +901 -0
- package/dist/NiceHtmlEditor-C1OVtLQ6.cjs +10 -0
- package/dist/NiceMention-CVxxCVtQ.js +11668 -0
- package/dist/NiceMention-Te66Oid1.cjs +430 -0
- package/dist/NiceModuleLifecyclePanel-DCrFyUH8.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-Mt80MdET.js +7441 -0
- package/dist/NicePagination-CKsAP38Q.cjs +1 -0
- package/dist/NicePagination-zOed5QxG.js +202 -0
- package/dist/NicePivotGrid-Clue9FM5.js +1184 -0
- package/dist/NicePivotGrid-Cnkr9WkC.cjs +152 -0
- package/dist/NiceSavedQueryPanel-NgG58w6i.js +6226 -0
- package/dist/NiceSavedQueryPanel-lTWY2plm.cjs +587 -0
- package/dist/NiceScheduler-BWwqFKEc.js +1712 -0
- package/dist/NiceScheduler-DqWEJU7g.cjs +5 -0
- package/dist/NiceSelect-BNPXs6FQ.cjs +1 -0
- package/dist/NiceSelect-DEruWHan.js +495 -0
- package/dist/NiceWindow-D3V7A69Q.js +2247 -0
- package/dist/NiceWindow-pgR4c-kQ.cjs +1 -0
- package/dist/core-lazy-Bjdu111n.js +351 -0
- package/dist/core-lazy-Bx_8BOlG.cjs +1 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +46 -5
- package/dist/data.mjs +3 -3
- package/dist/devops-CqhA0rjL.js +9130 -0
- package/dist/devops-cgRBnZVX.cjs +18 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.mjs +7 -7
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +1 -1
- package/dist/index.cjs +108 -108
- package/dist/index.css +1 -1
- package/dist/index.d.ts +51 -8
- package/dist/index.mjs +13739 -13579
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +15 -15
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +2 -0
- package/dist/navigation.mjs +3 -3
- package/dist/no-code-BQqK8mvU.cjs +331 -0
- package/dist/no-code-Cppb-xz3.js +8320 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.mjs +1 -1
- package/dist/pickerCommons-BA3-D5RC.js +663 -0
- package/dist/pickerCommons-KrBqCBDn.cjs +1 -0
- package/dist/style.css +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
import { jsx as o, jsxs as C } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as dt, useNiceAccessMode as mt, useControlId as ut, useControllableState as ft, useRovingFocus as pt, useOverlayFocus as ht, sanitizeHtml as ae, NiceTutorialButton as gt, resolveTutorial as bt, NiceIcon as D, clickOnActivationKey as xt } from "@nice2dev/ui-core";
|
|
3
|
+
import { useRef as N, useState as d, useCallback as m, useLayoutEffect as Ct, useMemo as yt } from "react";
|
|
4
|
+
import { N as w } from "./NiceButton-CnAIqCbd.js";
|
|
5
|
+
import { b as vt } from "./devops-CqhA0rjL.js";
|
|
6
|
+
import { N as kt } from "./NiceSelect-DEruWHan.js";
|
|
7
|
+
import { NiceColorPicker as Me } from "./NiceColorPicker-DS59tNkP.js";
|
|
8
|
+
function _e(u) {
|
|
9
|
+
const t = u.trim().toLowerCase();
|
|
10
|
+
return t.startsWith("http://") || t.startsWith("https://") || t.startsWith("/") || t.startsWith("./") || t.startsWith("../") ? !0 : !(t.startsWith("javascript:") || t.startsWith("vbscript:") || t.startsWith("data:text"));
|
|
11
|
+
}
|
|
12
|
+
function Ee(u) {
|
|
13
|
+
const t = typeof window < "u" ? window.getSelection() : null;
|
|
14
|
+
if (!t || t.rangeCount === 0)
|
|
15
|
+
return null;
|
|
16
|
+
const $ = t.getRangeAt(0);
|
|
17
|
+
return u.contains($.commonAncestorContainer) ? $.cloneRange() : null;
|
|
18
|
+
}
|
|
19
|
+
function Le(u) {
|
|
20
|
+
const t = typeof window < "u" ? window.getSelection() : null;
|
|
21
|
+
!t || !u || (t.removeAllRanges(), t.addRange(u));
|
|
22
|
+
}
|
|
23
|
+
const wt = [
|
|
24
|
+
{
|
|
25
|
+
target: ".nice-htmleditor",
|
|
26
|
+
titleKey: "tutorial.htmlEditor.intro.title",
|
|
27
|
+
title: "Rich text editor",
|
|
28
|
+
contentKey: "tutorial.htmlEditor.intro.content",
|
|
29
|
+
content: "Format text with the toolbar, insert links, images and tables, and switch to HTML or Markdown source when you need it.",
|
|
30
|
+
placement: "auto"
|
|
31
|
+
}
|
|
32
|
+
], Tt = [
|
|
33
|
+
"bold",
|
|
34
|
+
"italic",
|
|
35
|
+
"underline",
|
|
36
|
+
"strikethrough",
|
|
37
|
+
"h1",
|
|
38
|
+
"h2",
|
|
39
|
+
"h3",
|
|
40
|
+
"ul",
|
|
41
|
+
"ol",
|
|
42
|
+
"blockquote",
|
|
43
|
+
"hr",
|
|
44
|
+
"link",
|
|
45
|
+
"unlink",
|
|
46
|
+
"image",
|
|
47
|
+
"table",
|
|
48
|
+
"code",
|
|
49
|
+
"alignLeft",
|
|
50
|
+
"alignCenter",
|
|
51
|
+
"alignRight",
|
|
52
|
+
"fontSize",
|
|
53
|
+
"fontColor",
|
|
54
|
+
"undo",
|
|
55
|
+
"redo",
|
|
56
|
+
"clear",
|
|
57
|
+
"findReplace",
|
|
58
|
+
"emoji",
|
|
59
|
+
"source",
|
|
60
|
+
"fullscreen",
|
|
61
|
+
"markdown"
|
|
62
|
+
], a = (u) => /* @__PURE__ */ o(D, { name: u, size: 16 }), Ht = {
|
|
63
|
+
bold: /* @__PURE__ */ o("strong", { style: { fontFamily: "serif" }, children: "B" }),
|
|
64
|
+
italic: /* @__PURE__ */ o("em", { style: { fontFamily: "serif" }, children: "I" }),
|
|
65
|
+
underline: /* @__PURE__ */ o("span", { style: { textDecoration: "underline" }, children: "U" }),
|
|
66
|
+
strikethrough: /* @__PURE__ */ o("span", { style: { textDecoration: "line-through" }, children: "S" }),
|
|
67
|
+
h1: "H1",
|
|
68
|
+
h2: "H2",
|
|
69
|
+
h3: "H3",
|
|
70
|
+
ul: a("list"),
|
|
71
|
+
ol: a("list-ordered"),
|
|
72
|
+
link: a("link"),
|
|
73
|
+
unlink: a("unlink"),
|
|
74
|
+
undo: a("reply"),
|
|
75
|
+
redo: a("forward"),
|
|
76
|
+
clear: a("trash"),
|
|
77
|
+
table: a("table"),
|
|
78
|
+
image: a("image"),
|
|
79
|
+
code: a("code"),
|
|
80
|
+
markdown: "MD",
|
|
81
|
+
blockquote: a("quote"),
|
|
82
|
+
hr: a("minus"),
|
|
83
|
+
subscript: "X₂",
|
|
84
|
+
superscript: "X²",
|
|
85
|
+
indent: a("indent"),
|
|
86
|
+
outdent: a("outdent"),
|
|
87
|
+
alignLeft: a("align-left"),
|
|
88
|
+
alignCenter: a("align-center"),
|
|
89
|
+
alignRight: a("align-right"),
|
|
90
|
+
alignJustify: a("align-justify"),
|
|
91
|
+
fullscreen: a("expand"),
|
|
92
|
+
removeFormat: a("eraser"),
|
|
93
|
+
print: a("printer"),
|
|
94
|
+
source: a("terminal"),
|
|
95
|
+
emoji: a("smile"),
|
|
96
|
+
findReplace: a("search"),
|
|
97
|
+
fontSize: a("type"),
|
|
98
|
+
fontColor: a("palette")
|
|
99
|
+
}, Mt = [
|
|
100
|
+
{ value: "1", label: "8pt" },
|
|
101
|
+
{ value: "2", label: "10pt" },
|
|
102
|
+
{ value: "3", label: "12pt" },
|
|
103
|
+
{ value: "4", label: "14pt" },
|
|
104
|
+
{ value: "5", label: "18pt" },
|
|
105
|
+
{ value: "6", label: "24pt" },
|
|
106
|
+
{ value: "7", label: "36pt" }
|
|
107
|
+
], _t = [
|
|
108
|
+
{
|
|
109
|
+
label: "Faces",
|
|
110
|
+
emojis: ["😀", "😂", "😊", "😍", "🤔", "😢", "😎", "🥳", "😤", "🤯", "🥰", "😴"]
|
|
111
|
+
},
|
|
112
|
+
{ label: "Hands", emojis: ["👍", "👎", "👏", "🤝", "✌️", "🤞", "💪", "🙌", "👋", "🤙"] },
|
|
113
|
+
{
|
|
114
|
+
label: "Symbols",
|
|
115
|
+
emojis: ["❤️", "⭐", "🔥", "✅", "❌", "⚡", "💡", "📌", "🎯", "🏆", "🎉", "💬"]
|
|
116
|
+
},
|
|
117
|
+
{ label: "Arrows", emojis: ["➡️", "⬅️", "⬆️", "⬇️", "↩️", "🔄", "▶️", "⏸️", "⏹️", "⏩"] }
|
|
118
|
+
];
|
|
119
|
+
function Et(u) {
|
|
120
|
+
let t = u;
|
|
121
|
+
return t = t.replace(/<h1[^>]*>(.*?)<\/h1>/gi, `# $1
|
|
122
|
+
`), t = t.replace(/<h2[^>]*>(.*?)<\/h2>/gi, `## $1
|
|
123
|
+
`), t = t.replace(/<h3[^>]*>(.*?)<\/h3>/gi, `### $1
|
|
124
|
+
`), t = t.replace(/<strong[^>]*>(.*?)<\/strong>/gi, "**$1**"), t = t.replace(/<b[^>]*>(.*?)<\/b>/gi, "**$1**"), t = t.replace(/<em[^>]*>(.*?)<\/em>/gi, "*$1*"), t = t.replace(/<i[^>]*>(.*?)<\/i>/gi, "*$1*"), t = t.replace(/<code[^>]*>(.*?)<\/code>/gi, "`$1`"), t = t.replace(/<pre[^>]*>(.*?)<\/pre>/gis, "```\n$1\n```\n"), t = t.replace(/<br\s*\/?>/gi, `
|
|
125
|
+
`), t = t.replace(/<li[^>]*>(.*?)<\/li>/gi, `- $1
|
|
126
|
+
`), t = t.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi, `
|
|
127
|
+
`), t = t.replace(/<[^>]+>/g, ""), t = t.replace(/\n{3,}/g, `
|
|
128
|
+
|
|
129
|
+
`), t.trim();
|
|
130
|
+
}
|
|
131
|
+
function Lt(u) {
|
|
132
|
+
let t = u;
|
|
133
|
+
return t = t.replace(/^### (.+)$/gm, "<h3>$1</h3>"), t = t.replace(/^## (.+)$/gm, "<h2>$1</h2>"), t = t.replace(/^# (.+)$/gm, "<h1>$1</h1>"), t = t.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), t = t.replace(/\*(.+?)\*/g, "<em>$1</em>"), t = t.replace(/`([^`]+)`/g, "<code>$1</code>"), t = t.replace(/```\n?([\s\S]*?)\n?```/g, "<pre>$1</pre>"), t = t.replace(/^- (.+)$/gm, "<li>$1</li>"), t = t.replace(/(<li>.*<\/li>)/gs, "<ul>$1</ul>"), t = t.replace(/\n/g, "<br>"), t;
|
|
134
|
+
}
|
|
135
|
+
const jt = ({
|
|
136
|
+
value: u,
|
|
137
|
+
defaultValue: t,
|
|
138
|
+
onChange: $,
|
|
139
|
+
placeholder: Se,
|
|
140
|
+
height: K = 200,
|
|
141
|
+
toolbar: Re = Tt,
|
|
142
|
+
readOnly: b,
|
|
143
|
+
onImageUpload: L,
|
|
144
|
+
mentionTrigger: y,
|
|
145
|
+
mentionSuggestions: se,
|
|
146
|
+
onMentionSearch: ce,
|
|
147
|
+
onFileDrop: S,
|
|
148
|
+
pasteCleanup: de = !0,
|
|
149
|
+
maxLength: T = 0,
|
|
150
|
+
showWordCount: me = !1,
|
|
151
|
+
templates: W,
|
|
152
|
+
label: ue,
|
|
153
|
+
error: I,
|
|
154
|
+
helperText: fe,
|
|
155
|
+
required: ze,
|
|
156
|
+
disabled: x,
|
|
157
|
+
size: Ne = "md",
|
|
158
|
+
id: pe,
|
|
159
|
+
className: De,
|
|
160
|
+
style: $e,
|
|
161
|
+
accessMode: Ie,
|
|
162
|
+
tutorial: je
|
|
163
|
+
}) => {
|
|
164
|
+
const { t: c } = dt(), { prompt: A, element: Oe } = vt(), B = mt(Ie, pe), Fe = B === "hidden";
|
|
165
|
+
B === "disabled" && (x = !0), B === "readOnly" && (b = !0);
|
|
166
|
+
const he = ut(pe), [p, s] = ft({
|
|
167
|
+
value: u,
|
|
168
|
+
defaultValue: t,
|
|
169
|
+
fallbackValue: "",
|
|
170
|
+
onChange: $,
|
|
171
|
+
componentName: "NiceHtmlEditor"
|
|
172
|
+
}), f = N(null), [Ke] = d(() => ({ __html: p })), q = N(p);
|
|
173
|
+
q.current = p;
|
|
174
|
+
const We = m((e) => {
|
|
175
|
+
f.current = e, e && e.innerHTML !== q.current && (e.innerHTML = q.current);
|
|
176
|
+
}, []);
|
|
177
|
+
Ct(() => {
|
|
178
|
+
const e = f.current;
|
|
179
|
+
e && e.innerHTML !== p && (e.innerHTML = p);
|
|
180
|
+
}, [p]);
|
|
181
|
+
const ge = N(null), Ae = N(null), [H, P] = d(!1), [U, be] = d(""), [M, Q] = d(!1), [X, xe] = d(""), [J, j] = d(!1), [Ce, Be] = d(""), [V, G] = d(0), [Y, qe] = d(!1), [ye, Pe] = d("#000000"), [ve, Ue] = d("#ffff00"), [ke, O] = d(0), [Qe, Xe] = d(0), [Z, ee] = d(!1), [h, Je] = d(""), [R, Ve] = d(""), [te, we] = d(!1), [ne, re] = d(!1), oe = N(null);
|
|
182
|
+
pt(oe, { orientation: "vertical", wrap: !0 }), ht(oe, {
|
|
183
|
+
open: ne,
|
|
184
|
+
modal: !1,
|
|
185
|
+
onClose: () => re(!1)
|
|
186
|
+
});
|
|
187
|
+
const g = m(
|
|
188
|
+
(e, n) => {
|
|
189
|
+
if (b || x)
|
|
190
|
+
return;
|
|
191
|
+
if (e === "markdown") {
|
|
192
|
+
H ? (s(Lt(U)), P(!1)) : (be(Et(p)), P(!0), Q(!1));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (e === "source") {
|
|
196
|
+
M ? (s(X), Q(!1)) : (xe(p), Q(!0), P(!1));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const i = f.current;
|
|
200
|
+
if (i) {
|
|
201
|
+
if (e === "fullscreen") {
|
|
202
|
+
qe((r) => !r);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (e === "emoji") {
|
|
206
|
+
we((r) => !r);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (e === "findReplace") {
|
|
210
|
+
ee((r) => !r);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (e === "image") {
|
|
214
|
+
if (L)
|
|
215
|
+
ge.current?.click();
|
|
216
|
+
else {
|
|
217
|
+
const r = Ee(i);
|
|
218
|
+
A({
|
|
219
|
+
title: c("htmlEditor.imageUrlPrompt", "Image URL"),
|
|
220
|
+
inputType: "url",
|
|
221
|
+
placeholder: "https://"
|
|
222
|
+
}).then((l) => {
|
|
223
|
+
l && _e(l) && (i.focus(), Le(r), document.execCommand("insertImage", !1, l), s(ae(i.innerHTML)));
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
switch (i.focus(), e) {
|
|
229
|
+
case "bold":
|
|
230
|
+
document.execCommand("bold");
|
|
231
|
+
break;
|
|
232
|
+
case "italic":
|
|
233
|
+
document.execCommand("italic");
|
|
234
|
+
break;
|
|
235
|
+
case "underline":
|
|
236
|
+
document.execCommand("underline");
|
|
237
|
+
break;
|
|
238
|
+
case "strikethrough":
|
|
239
|
+
document.execCommand("strikeThrough");
|
|
240
|
+
break;
|
|
241
|
+
case "h1":
|
|
242
|
+
document.execCommand("formatBlock", !1, "h1");
|
|
243
|
+
break;
|
|
244
|
+
case "h2":
|
|
245
|
+
document.execCommand("formatBlock", !1, "h2");
|
|
246
|
+
break;
|
|
247
|
+
case "h3":
|
|
248
|
+
document.execCommand("formatBlock", !1, "h3");
|
|
249
|
+
break;
|
|
250
|
+
case "ul":
|
|
251
|
+
document.execCommand("insertUnorderedList");
|
|
252
|
+
break;
|
|
253
|
+
case "ol":
|
|
254
|
+
document.execCommand("insertOrderedList");
|
|
255
|
+
break;
|
|
256
|
+
case "blockquote":
|
|
257
|
+
document.execCommand("formatBlock", !1, "blockquote");
|
|
258
|
+
break;
|
|
259
|
+
case "hr":
|
|
260
|
+
document.execCommand("insertHorizontalRule");
|
|
261
|
+
break;
|
|
262
|
+
case "subscript":
|
|
263
|
+
document.execCommand("subscript");
|
|
264
|
+
break;
|
|
265
|
+
case "superscript":
|
|
266
|
+
document.execCommand("superscript");
|
|
267
|
+
break;
|
|
268
|
+
case "indent":
|
|
269
|
+
document.execCommand("indent");
|
|
270
|
+
break;
|
|
271
|
+
case "outdent":
|
|
272
|
+
document.execCommand("outdent");
|
|
273
|
+
break;
|
|
274
|
+
case "alignLeft":
|
|
275
|
+
document.execCommand("justifyLeft");
|
|
276
|
+
break;
|
|
277
|
+
case "alignCenter":
|
|
278
|
+
document.execCommand("justifyCenter");
|
|
279
|
+
break;
|
|
280
|
+
case "alignRight":
|
|
281
|
+
document.execCommand("justifyRight");
|
|
282
|
+
break;
|
|
283
|
+
case "alignJustify":
|
|
284
|
+
document.execCommand("justifyFull");
|
|
285
|
+
break;
|
|
286
|
+
case "removeFormat":
|
|
287
|
+
document.execCommand("removeFormat");
|
|
288
|
+
break;
|
|
289
|
+
case "print":
|
|
290
|
+
window.print();
|
|
291
|
+
return;
|
|
292
|
+
case "link": {
|
|
293
|
+
const r = Ee(i);
|
|
294
|
+
A({
|
|
295
|
+
title: c("htmlEditor.linkUrlPrompt", "Link URL"),
|
|
296
|
+
inputType: "url",
|
|
297
|
+
placeholder: "https://"
|
|
298
|
+
}).then((l) => {
|
|
299
|
+
l && _e(l) && (i.focus(), Le(r), document.execCommand("createLink", !1, l), s(ae(i.innerHTML)), O(i.textContent?.length ?? 0));
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
case "unlink":
|
|
304
|
+
document.execCommand("unlink");
|
|
305
|
+
break;
|
|
306
|
+
case "undo":
|
|
307
|
+
document.execCommand("undo");
|
|
308
|
+
break;
|
|
309
|
+
case "redo":
|
|
310
|
+
document.execCommand("redo");
|
|
311
|
+
break;
|
|
312
|
+
case "clear":
|
|
313
|
+
document.execCommand("removeFormat");
|
|
314
|
+
break;
|
|
315
|
+
case "fontSize": {
|
|
316
|
+
n && document.execCommand("fontSize", !1, n);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
case "fontColor": {
|
|
320
|
+
n && document.execCommand("foreColor", !1, n);
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
case "bgColor": {
|
|
324
|
+
n && document.execCommand("hiliteColor", !1, n);
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
case "table": {
|
|
328
|
+
document.execCommand("insertHTML", !1, '<table class="nice-htmleditor__table"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr></tbody></table><p> </p>');
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
case "code": {
|
|
332
|
+
const l = window.getSelection()?.toString() || "";
|
|
333
|
+
l.includes(`
|
|
334
|
+
`) || l.length > 60 ? document.execCommand(
|
|
335
|
+
"insertHTML",
|
|
336
|
+
!1,
|
|
337
|
+
`<pre class="nice-htmleditor__code-block">${l || "// code"}</pre>`
|
|
338
|
+
) : document.execCommand("insertHTML", !1, `<code>${l || "code"}</code>`);
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
s(ae(i.innerHTML)), O(i.textContent?.length ?? 0);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
[
|
|
346
|
+
s,
|
|
347
|
+
b,
|
|
348
|
+
x,
|
|
349
|
+
H,
|
|
350
|
+
U,
|
|
351
|
+
p,
|
|
352
|
+
L,
|
|
353
|
+
M,
|
|
354
|
+
X,
|
|
355
|
+
A,
|
|
356
|
+
c
|
|
357
|
+
]
|
|
358
|
+
), Ge = m(
|
|
359
|
+
async (e) => {
|
|
360
|
+
const n = e.target.files?.[0];
|
|
361
|
+
if (!n || !L)
|
|
362
|
+
return;
|
|
363
|
+
const i = await L(n), r = f.current;
|
|
364
|
+
r && i && (r.focus(), document.execCommand("insertImage", !1, i), s(r.innerHTML)), e.target.value = "";
|
|
365
|
+
},
|
|
366
|
+
[L, s]
|
|
367
|
+
), Ye = m(() => {
|
|
368
|
+
const e = f.current;
|
|
369
|
+
if (!e)
|
|
370
|
+
return;
|
|
371
|
+
const n = e.textContent?.length ?? 0;
|
|
372
|
+
if (T > 0 && n > T && (e.textContent = (e.textContent ?? "").slice(0, T)), O(n), Xe((e.textContent ?? "").trim().split(/\s+/).filter(Boolean).length), s(e.innerHTML), y) {
|
|
373
|
+
const i = window.getSelection();
|
|
374
|
+
if (i && i.rangeCount > 0) {
|
|
375
|
+
const r = i.getRangeAt(0), l = r.startContainer;
|
|
376
|
+
if (l.nodeType === Node.TEXT_NODE) {
|
|
377
|
+
const v = l.textContent || "", E = r.startOffset, F = v.slice(0, E), k = F.lastIndexOf(y);
|
|
378
|
+
if (k >= 0 && (k === 0 || /\s/.test(F[k - 1]))) {
|
|
379
|
+
const z = F.slice(k + y.length);
|
|
380
|
+
if (!/\s/.test(z)) {
|
|
381
|
+
j(!0), Be(z), G(0), ce?.(z);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
j(!1);
|
|
388
|
+
}
|
|
389
|
+
}, [T, s, y, ce]), _ = yt(
|
|
390
|
+
() => se?.filter((e) => e.label.toLowerCase().includes(Ce.toLowerCase())).slice(0, 8) ?? [],
|
|
391
|
+
[se, Ce]
|
|
392
|
+
), ie = m(
|
|
393
|
+
(e) => {
|
|
394
|
+
const n = f.current;
|
|
395
|
+
if (!n)
|
|
396
|
+
return;
|
|
397
|
+
const i = window.getSelection();
|
|
398
|
+
if (!i || i.rangeCount === 0)
|
|
399
|
+
return;
|
|
400
|
+
const r = i.getRangeAt(0), l = r.startContainer;
|
|
401
|
+
if (l.nodeType === Node.TEXT_NODE && y) {
|
|
402
|
+
const v = l.textContent || "", E = r.startOffset, k = v.slice(0, E).lastIndexOf(y);
|
|
403
|
+
if (k >= 0) {
|
|
404
|
+
const z = v.slice(0, k), at = v.slice(E), st = `<span class="nice-htmleditor__mention" data-mention="${e.key}" contenteditable="false">${y}${e.label}</span> `;
|
|
405
|
+
l.textContent = z;
|
|
406
|
+
const le = document.createRange();
|
|
407
|
+
le.setStartAfter(l), le.collapse(!0);
|
|
408
|
+
const ct = le.createContextualFragment(st + at);
|
|
409
|
+
l.parentNode?.insertBefore(ct, l.nextSibling), i.collapseToEnd(), s(n.innerHTML);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
j(!1);
|
|
413
|
+
},
|
|
414
|
+
[y, s]
|
|
415
|
+
), Ze = m(
|
|
416
|
+
(e) => {
|
|
417
|
+
if (J && _.length > 0) {
|
|
418
|
+
e.key === "ArrowDown" ? (e.preventDefault(), G((n) => Math.min(n + 1, _.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), G((n) => Math.max(n - 1, 0))) : e.key === "Enter" ? (e.preventDefault(), ie(_[V])) : e.key === "Escape" && j(!1);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
(e.ctrlKey || e.metaKey) && e.key === "b" ? (e.preventDefault(), g("bold")) : (e.ctrlKey || e.metaKey) && e.key === "i" ? (e.preventDefault(), g("italic")) : (e.ctrlKey || e.metaKey) && e.key === "u" ? (e.preventDefault(), g("underline")) : (e.ctrlKey || e.metaKey) && e.key === "f" ? (e.preventDefault(), ee((n) => !n)) : (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey ? (e.preventDefault(), g("undo")) : (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey) && (e.preventDefault(), g("redo"));
|
|
422
|
+
},
|
|
423
|
+
[J, _, V, ie, g]
|
|
424
|
+
), et = m(
|
|
425
|
+
(e) => {
|
|
426
|
+
if (!de)
|
|
427
|
+
return;
|
|
428
|
+
e.preventDefault();
|
|
429
|
+
const n = e.clipboardData.getData("text/html"), i = e.clipboardData.getData("text/plain");
|
|
430
|
+
if (n) {
|
|
431
|
+
const l = n.replace(/<style[\s\S]*?<\/style>/gi, "").replace(/<script[\s\S]*?<\/script>/gi, "").replace(/class="[^"]*"/gi, "").replace(/style="[^"]*"/gi, "").replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi, "").replace(/<!--[\s\S]*?-->/g, "").replace(/<\/?(?:xml|meta|link|font|span)[^>]*>/gi, "");
|
|
432
|
+
document.execCommand("insertHTML", !1, l);
|
|
433
|
+
} else i && document.execCommand("insertText", !1, i);
|
|
434
|
+
const r = f.current;
|
|
435
|
+
r && (s(r.innerHTML), O(r.textContent?.length ?? 0));
|
|
436
|
+
},
|
|
437
|
+
[de, s]
|
|
438
|
+
), tt = m(
|
|
439
|
+
async (e) => {
|
|
440
|
+
if (!S)
|
|
441
|
+
return;
|
|
442
|
+
e.preventDefault();
|
|
443
|
+
const n = Array.from(e.dataTransfer.files);
|
|
444
|
+
if (n.length === 0)
|
|
445
|
+
return;
|
|
446
|
+
const i = await S(n), r = f.current;
|
|
447
|
+
if (r) {
|
|
448
|
+
r.focus();
|
|
449
|
+
for (const l of i)
|
|
450
|
+
if (/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(l) || l.startsWith("data:image/"))
|
|
451
|
+
document.execCommand("insertImage", !1, l);
|
|
452
|
+
else {
|
|
453
|
+
const E = `<a href="${l}">${l.split("/").pop() ?? l}</a>`;
|
|
454
|
+
document.execCommand("insertHTML", !1, E);
|
|
455
|
+
}
|
|
456
|
+
s(r.innerHTML);
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
[S, s]
|
|
460
|
+
), nt = m(
|
|
461
|
+
(e) => {
|
|
462
|
+
S && e.preventDefault();
|
|
463
|
+
},
|
|
464
|
+
[S]
|
|
465
|
+
), Te = m(
|
|
466
|
+
(e) => {
|
|
467
|
+
const n = f.current;
|
|
468
|
+
if (!n || !h)
|
|
469
|
+
return;
|
|
470
|
+
const i = n.textContent ?? "", r = h.toLowerCase(), l = i.toLowerCase();
|
|
471
|
+
(e === 1 ? l.indexOf(r) : l.lastIndexOf(r)) !== -1 && (n.focus(), window.find?.(h));
|
|
472
|
+
},
|
|
473
|
+
[h]
|
|
474
|
+
), rt = m(() => {
|
|
475
|
+
const e = f.current;
|
|
476
|
+
!e || !h || (e.innerHTML = e.innerHTML.split(h).join(R), s(e.innerHTML));
|
|
477
|
+
}, [h, R, s]), ot = m(() => {
|
|
478
|
+
if (!h)
|
|
479
|
+
return;
|
|
480
|
+
const e = p.split(h).join(R);
|
|
481
|
+
s(e);
|
|
482
|
+
const n = f.current;
|
|
483
|
+
n && (n.innerHTML = e);
|
|
484
|
+
}, [h, R, p, s]), it = m(
|
|
485
|
+
(e) => {
|
|
486
|
+
const n = f.current;
|
|
487
|
+
n && (n.focus(), document.execCommand("insertText", !1, e), s(n.innerHTML), we(!1));
|
|
488
|
+
},
|
|
489
|
+
[s]
|
|
490
|
+
), He = m(
|
|
491
|
+
(e) => {
|
|
492
|
+
const n = f.current;
|
|
493
|
+
n && (n.focus(), document.execCommand("insertHTML", !1, e), s(n.innerHTML), re(!1));
|
|
494
|
+
},
|
|
495
|
+
[s]
|
|
496
|
+
), lt = m(
|
|
497
|
+
(e) => {
|
|
498
|
+
const n = x || b;
|
|
499
|
+
return e === "fontSize" ? /* @__PURE__ */ o(
|
|
500
|
+
kt,
|
|
501
|
+
{
|
|
502
|
+
size: "sm",
|
|
503
|
+
value: "",
|
|
504
|
+
onChange: (r) => g("fontSize", String(r)),
|
|
505
|
+
disabled: n,
|
|
506
|
+
placeholder: c("htmlEditor.size", "Size"),
|
|
507
|
+
options: Mt.map((r) => ({ value: r.value, label: r.label })),
|
|
508
|
+
style: { minWidth: 70, maxWidth: 80 }
|
|
509
|
+
},
|
|
510
|
+
e
|
|
511
|
+
) : e === "fontColor" ? /* @__PURE__ */ o(
|
|
512
|
+
Me,
|
|
513
|
+
{
|
|
514
|
+
value: ye,
|
|
515
|
+
onChange: (r) => {
|
|
516
|
+
Pe(r), g("fontColor", r);
|
|
517
|
+
},
|
|
518
|
+
disabled: n,
|
|
519
|
+
size: "sm",
|
|
520
|
+
label: "",
|
|
521
|
+
title: c("htmlEditor.textColor", "Text color")
|
|
522
|
+
},
|
|
523
|
+
e
|
|
524
|
+
) : e === "bgColor" ? /* @__PURE__ */ o(
|
|
525
|
+
Me,
|
|
526
|
+
{
|
|
527
|
+
value: ve,
|
|
528
|
+
onChange: (r) => {
|
|
529
|
+
Ue(r), g("bgColor", r);
|
|
530
|
+
},
|
|
531
|
+
disabled: n,
|
|
532
|
+
size: "sm",
|
|
533
|
+
label: "",
|
|
534
|
+
title: c("htmlEditor.highlightColor", "Highlight color")
|
|
535
|
+
},
|
|
536
|
+
e
|
|
537
|
+
) : /* @__PURE__ */ o(
|
|
538
|
+
w,
|
|
539
|
+
{
|
|
540
|
+
size: "sm",
|
|
541
|
+
variant: e === "markdown" && H || e === "fullscreen" && Y || e === "source" && M || e === "findReplace" && Z || e === "emoji" && te ? "primary" : "ghost",
|
|
542
|
+
onClick: () => g(e),
|
|
543
|
+
title: e,
|
|
544
|
+
disabled: n,
|
|
545
|
+
children: Ht[e] || e
|
|
546
|
+
},
|
|
547
|
+
e
|
|
548
|
+
);
|
|
549
|
+
},
|
|
550
|
+
[
|
|
551
|
+
x,
|
|
552
|
+
b,
|
|
553
|
+
g,
|
|
554
|
+
H,
|
|
555
|
+
Y,
|
|
556
|
+
ye,
|
|
557
|
+
ve,
|
|
558
|
+
M,
|
|
559
|
+
Z,
|
|
560
|
+
te,
|
|
561
|
+
c
|
|
562
|
+
]
|
|
563
|
+
);
|
|
564
|
+
return Fe ? null : /* @__PURE__ */ C(
|
|
565
|
+
"div",
|
|
566
|
+
{
|
|
567
|
+
className: `nice-field nice-field--${Ne} ${I ? "nice-field--error" : ""} ${De || ""}`,
|
|
568
|
+
style: $e,
|
|
569
|
+
children: [
|
|
570
|
+
Oe,
|
|
571
|
+
ue && /* @__PURE__ */ C("label", { className: "nice-field__label", htmlFor: he, children: [
|
|
572
|
+
ue,
|
|
573
|
+
ze && /* @__PURE__ */ o("span", { className: "nice-field__required", children: "*" })
|
|
574
|
+
] }),
|
|
575
|
+
/* @__PURE__ */ C(
|
|
576
|
+
"div",
|
|
577
|
+
{
|
|
578
|
+
ref: Ae,
|
|
579
|
+
className: `nice-htmleditor${Y ? " nice-htmleditor--fullscreen" : ""}`,
|
|
580
|
+
style: { position: "relative" },
|
|
581
|
+
children: [
|
|
582
|
+
/* @__PURE__ */ o("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 20 }, children: /* @__PURE__ */ o(gt, { steps: bt(je, wt) }) }),
|
|
583
|
+
/* @__PURE__ */ C(
|
|
584
|
+
"div",
|
|
585
|
+
{
|
|
586
|
+
className: "nice-htmleditor__toolbar",
|
|
587
|
+
style: { display: "flex", flexWrap: "wrap", gap: 2, alignItems: "center" },
|
|
588
|
+
children: [
|
|
589
|
+
Re.map(lt),
|
|
590
|
+
W && W.length > 0 && /* @__PURE__ */ C("div", { style: { position: "relative" }, children: [
|
|
591
|
+
/* @__PURE__ */ o(
|
|
592
|
+
w,
|
|
593
|
+
{
|
|
594
|
+
size: "sm",
|
|
595
|
+
variant: ne ? "primary" : "ghost",
|
|
596
|
+
onClick: () => re((e) => !e),
|
|
597
|
+
title: c("htmlEditor.insertTemplate", "Insert template"),
|
|
598
|
+
children: /* @__PURE__ */ o(D, { name: "clipboard", size: 16 })
|
|
599
|
+
}
|
|
600
|
+
),
|
|
601
|
+
ne && /* @__PURE__ */ o(
|
|
602
|
+
"ul",
|
|
603
|
+
{
|
|
604
|
+
ref: oe,
|
|
605
|
+
role: "menu",
|
|
606
|
+
"aria-label": c("htmlEditor.insertTemplate", "Insert template"),
|
|
607
|
+
style: {
|
|
608
|
+
position: "absolute",
|
|
609
|
+
top: "100%",
|
|
610
|
+
right: 0,
|
|
611
|
+
zIndex: 200,
|
|
612
|
+
background: "var(--nice-bg-primary, #fff)",
|
|
613
|
+
border: "1px solid var(--nice-border-color, #ddd)",
|
|
614
|
+
borderRadius: 6,
|
|
615
|
+
boxShadow: "0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",
|
|
616
|
+
listStyle: "none",
|
|
617
|
+
margin: 0,
|
|
618
|
+
padding: 4,
|
|
619
|
+
minWidth: 160,
|
|
620
|
+
maxHeight: 200,
|
|
621
|
+
overflow: "auto"
|
|
622
|
+
},
|
|
623
|
+
children: W.map((e, n) => /* @__PURE__ */ o(
|
|
624
|
+
"li",
|
|
625
|
+
{
|
|
626
|
+
role: "menuitem",
|
|
627
|
+
tabIndex: -1,
|
|
628
|
+
style: { padding: "6px 10px", cursor: "pointer", borderRadius: 4 },
|
|
629
|
+
onMouseDown: (i) => {
|
|
630
|
+
i.preventDefault(), He(e.html);
|
|
631
|
+
},
|
|
632
|
+
onKeyDown: (i) => {
|
|
633
|
+
(i.key === "Enter" || i.key === " ") && (i.preventDefault(), He(e.html));
|
|
634
|
+
},
|
|
635
|
+
children: e.label
|
|
636
|
+
},
|
|
637
|
+
n
|
|
638
|
+
))
|
|
639
|
+
}
|
|
640
|
+
)
|
|
641
|
+
] })
|
|
642
|
+
]
|
|
643
|
+
}
|
|
644
|
+
),
|
|
645
|
+
Z && /* @__PURE__ */ C(
|
|
646
|
+
"div",
|
|
647
|
+
{
|
|
648
|
+
className: "nice-htmleditor__find-bar",
|
|
649
|
+
style: {
|
|
650
|
+
display: "flex",
|
|
651
|
+
gap: 4,
|
|
652
|
+
alignItems: "center",
|
|
653
|
+
padding: "4px 8px",
|
|
654
|
+
background: "var(--nice-bg-secondary, #f8f9fa)",
|
|
655
|
+
borderBottom: "1px solid var(--nice-border-color, #ddd)",
|
|
656
|
+
fontSize: "0.875em"
|
|
657
|
+
},
|
|
658
|
+
children: [
|
|
659
|
+
/* @__PURE__ */ o(
|
|
660
|
+
"input",
|
|
661
|
+
{
|
|
662
|
+
type: "text",
|
|
663
|
+
placeholder: c("htmlEditor.find", "Find..."),
|
|
664
|
+
value: h,
|
|
665
|
+
onChange: (e) => Je(e.target.value),
|
|
666
|
+
style: {
|
|
667
|
+
flex: 1,
|
|
668
|
+
maxWidth: 180,
|
|
669
|
+
padding: "2px 6px",
|
|
670
|
+
border: "1px solid var(--nice-border-color, #ccc)",
|
|
671
|
+
borderRadius: 4,
|
|
672
|
+
background: "var(--nice-bg-primary, #fff)",
|
|
673
|
+
color: "var(--nice-text-primary, #1f2937)"
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
),
|
|
677
|
+
/* @__PURE__ */ o(
|
|
678
|
+
"input",
|
|
679
|
+
{
|
|
680
|
+
type: "text",
|
|
681
|
+
placeholder: c("htmlEditor.replace", "Replace..."),
|
|
682
|
+
value: R,
|
|
683
|
+
onChange: (e) => Ve(e.target.value),
|
|
684
|
+
style: {
|
|
685
|
+
flex: 1,
|
|
686
|
+
maxWidth: 180,
|
|
687
|
+
padding: "2px 6px",
|
|
688
|
+
border: "1px solid var(--nice-border-color, #ccc)",
|
|
689
|
+
borderRadius: 4,
|
|
690
|
+
background: "var(--nice-bg-primary, #fff)",
|
|
691
|
+
color: "var(--nice-text-primary, #1f2937)"
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
/* @__PURE__ */ o(
|
|
696
|
+
w,
|
|
697
|
+
{
|
|
698
|
+
size: "sm",
|
|
699
|
+
variant: "ghost",
|
|
700
|
+
onClick: () => Te(1),
|
|
701
|
+
title: c("htmlEditor.findNext", "Find next"),
|
|
702
|
+
children: /* @__PURE__ */ o(D, { name: "chevron-right", size: 14 })
|
|
703
|
+
}
|
|
704
|
+
),
|
|
705
|
+
/* @__PURE__ */ o(
|
|
706
|
+
w,
|
|
707
|
+
{
|
|
708
|
+
size: "sm",
|
|
709
|
+
variant: "ghost",
|
|
710
|
+
onClick: () => Te(-1),
|
|
711
|
+
title: c("htmlEditor.findPrevious", "Find previous"),
|
|
712
|
+
children: /* @__PURE__ */ o(D, { name: "chevron-left", size: 14 })
|
|
713
|
+
}
|
|
714
|
+
),
|
|
715
|
+
/* @__PURE__ */ o(
|
|
716
|
+
w,
|
|
717
|
+
{
|
|
718
|
+
size: "sm",
|
|
719
|
+
variant: "ghost",
|
|
720
|
+
onClick: rt,
|
|
721
|
+
disabled: x || b,
|
|
722
|
+
children: c("htmlEditor.replace2", "Replace")
|
|
723
|
+
}
|
|
724
|
+
),
|
|
725
|
+
/* @__PURE__ */ o(
|
|
726
|
+
w,
|
|
727
|
+
{
|
|
728
|
+
size: "sm",
|
|
729
|
+
variant: "ghost",
|
|
730
|
+
onClick: ot,
|
|
731
|
+
disabled: x || b,
|
|
732
|
+
children: c("htmlEditor.all", "All")
|
|
733
|
+
}
|
|
734
|
+
),
|
|
735
|
+
/* @__PURE__ */ o(w, { size: "sm", variant: "ghost", onClick: () => ee(!1), children: /* @__PURE__ */ o(D, { name: "close", size: 14, title: c("htmlEditor.close", "Close") }) })
|
|
736
|
+
]
|
|
737
|
+
}
|
|
738
|
+
),
|
|
739
|
+
te && /* @__PURE__ */ o(
|
|
740
|
+
"div",
|
|
741
|
+
{
|
|
742
|
+
className: "nice-htmleditor__emoji-picker",
|
|
743
|
+
style: {
|
|
744
|
+
padding: 8,
|
|
745
|
+
background: "var(--nice-bg-primary, #fff)",
|
|
746
|
+
borderBottom: "1px solid var(--nice-border-color, #ddd)",
|
|
747
|
+
maxHeight: 180,
|
|
748
|
+
overflowY: "auto"
|
|
749
|
+
},
|
|
750
|
+
children: _t.map((e) => /* @__PURE__ */ C("div", { children: [
|
|
751
|
+
/* @__PURE__ */ o(
|
|
752
|
+
"div",
|
|
753
|
+
{
|
|
754
|
+
style: {
|
|
755
|
+
fontSize: "0.7em",
|
|
756
|
+
fontWeight: 600,
|
|
757
|
+
color: "var(--nice-text-muted, #999)",
|
|
758
|
+
padding: "4px 0"
|
|
759
|
+
},
|
|
760
|
+
children: e.label
|
|
761
|
+
}
|
|
762
|
+
),
|
|
763
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", flexWrap: "wrap", gap: 2 }, children: e.emojis.map((n) => /* @__PURE__ */ o(
|
|
764
|
+
"span",
|
|
765
|
+
{
|
|
766
|
+
role: "button",
|
|
767
|
+
tabIndex: 0,
|
|
768
|
+
onKeyDown: xt,
|
|
769
|
+
style: { cursor: "pointer", fontSize: "1.2em", padding: 2, borderRadius: 4 },
|
|
770
|
+
onClick: () => it(n),
|
|
771
|
+
title: n,
|
|
772
|
+
children: n
|
|
773
|
+
},
|
|
774
|
+
n
|
|
775
|
+
)) })
|
|
776
|
+
] }, e.label))
|
|
777
|
+
}
|
|
778
|
+
),
|
|
779
|
+
/* @__PURE__ */ o(
|
|
780
|
+
"input",
|
|
781
|
+
{
|
|
782
|
+
ref: ge,
|
|
783
|
+
type: "file",
|
|
784
|
+
accept: "image/*",
|
|
785
|
+
style: { display: "none" },
|
|
786
|
+
onChange: Ge
|
|
787
|
+
}
|
|
788
|
+
),
|
|
789
|
+
M ? /* @__PURE__ */ o(
|
|
790
|
+
"textarea",
|
|
791
|
+
{
|
|
792
|
+
className: "nice-htmleditor__source",
|
|
793
|
+
value: X,
|
|
794
|
+
onChange: (e) => xe(e.target.value),
|
|
795
|
+
style: {
|
|
796
|
+
minHeight: K,
|
|
797
|
+
width: "100%",
|
|
798
|
+
fontFamily: "monospace",
|
|
799
|
+
resize: "vertical",
|
|
800
|
+
whiteSpace: "pre",
|
|
801
|
+
fontSize: "0.85em",
|
|
802
|
+
background: "var(--nice-bg-primary, #fff)",
|
|
803
|
+
color: "var(--nice-text-primary, #1f2937)",
|
|
804
|
+
border: "none",
|
|
805
|
+
padding: 12,
|
|
806
|
+
boxSizing: "border-box",
|
|
807
|
+
outline: "none"
|
|
808
|
+
},
|
|
809
|
+
disabled: x || b
|
|
810
|
+
}
|
|
811
|
+
) : H ? /* @__PURE__ */ o(
|
|
812
|
+
"textarea",
|
|
813
|
+
{
|
|
814
|
+
className: "nice-htmleditor__markdown",
|
|
815
|
+
value: U,
|
|
816
|
+
onChange: (e) => be(e.target.value),
|
|
817
|
+
style: {
|
|
818
|
+
minHeight: K,
|
|
819
|
+
width: "100%",
|
|
820
|
+
fontFamily: "monospace",
|
|
821
|
+
resize: "vertical",
|
|
822
|
+
background: "var(--nice-bg-primary, #fff)",
|
|
823
|
+
color: "var(--nice-text-primary, #1f2937)",
|
|
824
|
+
border: "none",
|
|
825
|
+
padding: 12,
|
|
826
|
+
boxSizing: "border-box",
|
|
827
|
+
outline: "none"
|
|
828
|
+
},
|
|
829
|
+
disabled: x || b
|
|
830
|
+
}
|
|
831
|
+
) : /* @__PURE__ */ C("div", { style: { position: "relative" }, children: [
|
|
832
|
+
/* @__PURE__ */ o(
|
|
833
|
+
"div",
|
|
834
|
+
{
|
|
835
|
+
ref: We,
|
|
836
|
+
id: he,
|
|
837
|
+
className: "nice-htmleditor__content",
|
|
838
|
+
contentEditable: !x && !b,
|
|
839
|
+
dangerouslySetInnerHTML: Ke,
|
|
840
|
+
onInput: Ye,
|
|
841
|
+
onKeyDown: Ze,
|
|
842
|
+
onPaste: et,
|
|
843
|
+
onDrop: tt,
|
|
844
|
+
onDragOver: nt,
|
|
845
|
+
style: { minHeight: K },
|
|
846
|
+
"data-placeholder": Se,
|
|
847
|
+
role: "textbox",
|
|
848
|
+
"aria-multiline": "true",
|
|
849
|
+
suppressContentEditableWarning: !0
|
|
850
|
+
}
|
|
851
|
+
),
|
|
852
|
+
J && _.length > 0 && /* @__PURE__ */ o("ul", { className: "nice-htmleditor__mention-list", children: _.map((e, n) => /* @__PURE__ */ o(
|
|
853
|
+
"li",
|
|
854
|
+
{
|
|
855
|
+
role: "presentation",
|
|
856
|
+
className: `nice-htmleditor__mention-item ${n === V ? "nice-htmleditor__mention-item--active" : ""}`,
|
|
857
|
+
onMouseDown: (i) => {
|
|
858
|
+
i.preventDefault(), ie(e);
|
|
859
|
+
},
|
|
860
|
+
children: e.label
|
|
861
|
+
},
|
|
862
|
+
e.key
|
|
863
|
+
)) })
|
|
864
|
+
] }),
|
|
865
|
+
/* @__PURE__ */ C(
|
|
866
|
+
"div",
|
|
867
|
+
{
|
|
868
|
+
className: "nice-htmleditor__statusbar",
|
|
869
|
+
style: {
|
|
870
|
+
display: "flex",
|
|
871
|
+
gap: 12,
|
|
872
|
+
padding: "2px 8px",
|
|
873
|
+
fontSize: "0.75em",
|
|
874
|
+
color: "var(--nice-text-muted, #666)",
|
|
875
|
+
borderTop: "1px solid var(--nice-border-color, #eee)"
|
|
876
|
+
},
|
|
877
|
+
children: [
|
|
878
|
+
T > 0 && /* @__PURE__ */ C("span", { children: [
|
|
879
|
+
ke,
|
|
880
|
+
" / ",
|
|
881
|
+
T
|
|
882
|
+
] }),
|
|
883
|
+
me && /* @__PURE__ */ o("span", { children: c("htmlEditor.words", "{wordCount} words").replace("{wordCount}", String(Qe)) }),
|
|
884
|
+
me && /* @__PURE__ */ o("span", { children: c("htmlEditor.chars", "{charCount} chars").replace("{charCount}", String(ke)) }),
|
|
885
|
+
M && /* @__PURE__ */ o("span", { style: { fontWeight: 600 }, children: c("htmlEditor.htmlSource", "HTML Source") }),
|
|
886
|
+
H && /* @__PURE__ */ o("span", { style: { fontWeight: 600 }, children: c("htmlEditor.markdown", "Markdown") })
|
|
887
|
+
]
|
|
888
|
+
}
|
|
889
|
+
)
|
|
890
|
+
]
|
|
891
|
+
}
|
|
892
|
+
),
|
|
893
|
+
I && /* @__PURE__ */ o("div", { className: "nice-field__error", children: I }),
|
|
894
|
+
fe && !I && /* @__PURE__ */ o("div", { className: "nice-field__hint", children: fe })
|
|
895
|
+
]
|
|
896
|
+
}
|
|
897
|
+
);
|
|
898
|
+
};
|
|
899
|
+
export {
|
|
900
|
+
jt as NiceHtmlEditor
|
|
901
|
+
};
|