teem-editor 0.1.0
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/LICENSE +21 -0
- package/README.md +186 -0
- package/dist/index.d.ts +85 -0
- package/dist/teem-editor.cjs +2 -0
- package/dist/teem-editor.cjs.map +1 -0
- package/dist/teem-editor.css +1 -0
- package/dist/teem-editor.js +2200 -0
- package/dist/teem-editor.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,2200 @@
|
|
|
1
|
+
import { jsxs as d, jsx as i, Fragment as ve } from "react/jsx-runtime";
|
|
2
|
+
import { useState as E, useRef as F, useEffect as G, useId as ut, forwardRef as dt, useCallback as A, useImperativeHandle as ft } from "react";
|
|
3
|
+
import gt from "dompurify";
|
|
4
|
+
const b = {
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeWidth: 1.8,
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round"
|
|
10
|
+
};
|
|
11
|
+
function L({ children: e, size: t = 18 }) {
|
|
12
|
+
return /* @__PURE__ */ i(
|
|
13
|
+
"svg",
|
|
14
|
+
{
|
|
15
|
+
width: t,
|
|
16
|
+
height: t,
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
"aria-hidden": "true",
|
|
19
|
+
focusable: "false",
|
|
20
|
+
children: e
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const C = {
|
|
25
|
+
undo: /* @__PURE__ */ d(L, { children: [
|
|
26
|
+
/* @__PURE__ */ i("path", { ...b, d: "M9 14L4 9l5-5" }),
|
|
27
|
+
/* @__PURE__ */ i("path", { ...b, d: "M4 9h10a6 6 0 010 12h-3" })
|
|
28
|
+
] }),
|
|
29
|
+
redo: /* @__PURE__ */ d(L, { children: [
|
|
30
|
+
/* @__PURE__ */ i("path", { ...b, d: "M15 14l5-5-5-5" }),
|
|
31
|
+
/* @__PURE__ */ i("path", { ...b, d: "M20 9H10a6 6 0 000 12h3" })
|
|
32
|
+
] }),
|
|
33
|
+
bold: /* @__PURE__ */ d(L, { children: [
|
|
34
|
+
/* @__PURE__ */ i(
|
|
35
|
+
"path",
|
|
36
|
+
{
|
|
37
|
+
fill: "none",
|
|
38
|
+
stroke: "currentColor",
|
|
39
|
+
strokeWidth: 2.8,
|
|
40
|
+
strokeLinecap: "round",
|
|
41
|
+
strokeLinejoin: "round",
|
|
42
|
+
d: "M7 5h6a3.5 3.5 0 010 7H7z"
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ i(
|
|
46
|
+
"path",
|
|
47
|
+
{
|
|
48
|
+
fill: "none",
|
|
49
|
+
stroke: "currentColor",
|
|
50
|
+
strokeWidth: 2.8,
|
|
51
|
+
strokeLinecap: "round",
|
|
52
|
+
strokeLinejoin: "round",
|
|
53
|
+
d: "M7 12h7a3.5 3.5 0 010 7H7z"
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] }),
|
|
57
|
+
italic: /* @__PURE__ */ d(L, { children: [
|
|
58
|
+
/* @__PURE__ */ i("path", { ...b, d: "M10 5h8" }),
|
|
59
|
+
/* @__PURE__ */ i("path", { ...b, d: "M6 19h8" }),
|
|
60
|
+
/* @__PURE__ */ i("path", { ...b, d: "M14 5l-4 14" })
|
|
61
|
+
] }),
|
|
62
|
+
strike: /* @__PURE__ */ d(L, { children: [
|
|
63
|
+
/* @__PURE__ */ i("path", { ...b, d: "M5 12h14" }),
|
|
64
|
+
/* @__PURE__ */ i("path", { ...b, d: "M16 7.5A4 4 0 0012 6c-2.8 0-4.5 1.5-4.5 3.2 0 3.3 7.5 1.7 7.5 5.1A3.4 3.4 0 0112 18c-2.2 0-4-1-4.8-2.4" })
|
|
65
|
+
] }),
|
|
66
|
+
ul: /* @__PURE__ */ d(L, { children: [
|
|
67
|
+
/* @__PURE__ */ i("path", { ...b, d: "M9 6h11M9 12h11M9 18h11" }),
|
|
68
|
+
/* @__PURE__ */ i("circle", { cx: "5", cy: "6", r: "1.2", fill: "currentColor" }),
|
|
69
|
+
/* @__PURE__ */ i("circle", { cx: "5", cy: "12", r: "1.2", fill: "currentColor" }),
|
|
70
|
+
/* @__PURE__ */ i("circle", { cx: "5", cy: "18", r: "1.2", fill: "currentColor" })
|
|
71
|
+
] }),
|
|
72
|
+
ol: /* @__PURE__ */ d(L, { children: [
|
|
73
|
+
/* @__PURE__ */ i("path", { ...b, d: "M11 6h9M11 12h9M11 18h9" }),
|
|
74
|
+
/* @__PURE__ */ d(
|
|
75
|
+
"g",
|
|
76
|
+
{
|
|
77
|
+
fill: "currentColor",
|
|
78
|
+
stroke: "none",
|
|
79
|
+
fontSize: "8",
|
|
80
|
+
fontWeight: "700",
|
|
81
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ i("text", { x: "3.5", y: "8", children: "1" }),
|
|
84
|
+
/* @__PURE__ */ i("text", { x: "3.5", y: "14.2", children: "2" }),
|
|
85
|
+
/* @__PURE__ */ i("text", { x: "3.5", y: "20.4", children: "3" })
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }),
|
|
90
|
+
quote: /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i("path", { fill: "currentColor", stroke: "none", d: "M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z" }) }),
|
|
91
|
+
alignRight: /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i("path", { ...b, d: "M4 6h16M8 12h12M4 18h16" }) }),
|
|
92
|
+
alignCenter: /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i("path", { ...b, d: "M4 6h16M7 12h10M4 18h16" }) }),
|
|
93
|
+
alignLeft: /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i("path", { ...b, d: "M4 6h16M4 12h12M4 18h16" }) }),
|
|
94
|
+
link: /* @__PURE__ */ d(L, { children: [
|
|
95
|
+
/* @__PURE__ */ i("path", { ...b, d: "M10 13a5 5 0 007.07 0l1.41-1.41a5 5 0 00-7.07-7.07L10 5.93" }),
|
|
96
|
+
/* @__PURE__ */ i("path", { ...b, d: "M14 11a5 5 0 00-7.07 0L5.52 12.4a5 5 0 007.07 7.07L14 18.07" })
|
|
97
|
+
] }),
|
|
98
|
+
image: /* @__PURE__ */ d(L, { children: [
|
|
99
|
+
/* @__PURE__ */ i("rect", { ...b, x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
100
|
+
/* @__PURE__ */ i("circle", { cx: "9", cy: "10", r: "1.5", fill: "currentColor" }),
|
|
101
|
+
/* @__PURE__ */ i("path", { ...b, d: "M3 16l5-4 4 3 3-2 6 3" })
|
|
102
|
+
] }),
|
|
103
|
+
rtl: /* @__PURE__ */ d(L, { children: [
|
|
104
|
+
/* @__PURE__ */ i(
|
|
105
|
+
"path",
|
|
106
|
+
{
|
|
107
|
+
fill: "currentColor",
|
|
108
|
+
stroke: "none",
|
|
109
|
+
d: "M9 10v5h2V4h2v11h2V4h2V2H9C6.79 2 5 3.79 5 6s1.79 4 4 4z"
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ i("path", { fill: "currentColor", stroke: "none", d: "M3 18l4-4v3H19v2H7v3l-4-4z" })
|
|
113
|
+
] }),
|
|
114
|
+
ltr: /* @__PURE__ */ d(L, { children: [
|
|
115
|
+
/* @__PURE__ */ i("g", { transform: "translate(24 0) scale(-1 1)", children: /* @__PURE__ */ i(
|
|
116
|
+
"path",
|
|
117
|
+
{
|
|
118
|
+
fill: "currentColor",
|
|
119
|
+
stroke: "none",
|
|
120
|
+
d: "M9 10v5h2V4h2v11h2V4h2V2H9C6.79 2 5 3.79 5 6s1.79 4 4 4z"
|
|
121
|
+
}
|
|
122
|
+
) }),
|
|
123
|
+
/* @__PURE__ */ i("path", { fill: "currentColor", stroke: "none", d: "M21 18l-4-4v3H5v2h12v3l4-4z" })
|
|
124
|
+
] }),
|
|
125
|
+
hr: /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i("path", { ...b, d: "M4 12h16" }) }),
|
|
126
|
+
indent: /* @__PURE__ */ d(L, { children: [
|
|
127
|
+
/* @__PURE__ */ i("path", { ...b, d: "M4 6h16M12 12h8M4 18h16" }),
|
|
128
|
+
/* @__PURE__ */ i("path", { ...b, d: "M4 9l4 3-4 3" })
|
|
129
|
+
] }),
|
|
130
|
+
outdent: /* @__PURE__ */ d(L, { children: [
|
|
131
|
+
/* @__PURE__ */ i("path", { ...b, d: "M4 6h16M12 12h8M4 18h16" }),
|
|
132
|
+
/* @__PURE__ */ i("path", { ...b, d: "M8 9L4 12l4 3" })
|
|
133
|
+
] }),
|
|
134
|
+
textColor: /* @__PURE__ */ d(L, { children: [
|
|
135
|
+
/* @__PURE__ */ i("path", { ...b, d: "M6 16l3.5-9h1L14 16" }),
|
|
136
|
+
/* @__PURE__ */ i("path", { ...b, d: "M7.5 13h5" })
|
|
137
|
+
] }),
|
|
138
|
+
bgColor: /* @__PURE__ */ d(L, { children: [
|
|
139
|
+
/* @__PURE__ */ i("path", { ...b, d: "M8 4l8 8-4 4-8-8z" }),
|
|
140
|
+
/* @__PURE__ */ i("path", { ...b, d: "M5 19h10" })
|
|
141
|
+
] }),
|
|
142
|
+
chevronDown: /* @__PURE__ */ i(L, { size: 12, children: /* @__PURE__ */ i("path", { ...b, d: "M6 9l6 6 6-6" }) }),
|
|
143
|
+
code: /* @__PURE__ */ d(L, { children: [
|
|
144
|
+
/* @__PURE__ */ i("path", { ...b, d: "M8 8L4 12l4 4" }),
|
|
145
|
+
/* @__PURE__ */ i("path", { ...b, d: "M16 8l4 4-4 4" }),
|
|
146
|
+
/* @__PURE__ */ i("path", { ...b, d: "M14 5l-4 14" })
|
|
147
|
+
] }),
|
|
148
|
+
close: /* @__PURE__ */ i(L, { size: 16, children: /* @__PURE__ */ i("path", { ...b, d: "M6 6l12 12M18 6L6 18" }) })
|
|
149
|
+
}, ht = {
|
|
150
|
+
placeholder: "Write something…",
|
|
151
|
+
toolbar: "TeemEditor toolbar",
|
|
152
|
+
undo: "Undo",
|
|
153
|
+
redo: "Redo",
|
|
154
|
+
blockType: "Block type",
|
|
155
|
+
paragraph: "Paragraph",
|
|
156
|
+
heading1: "Heading 1",
|
|
157
|
+
heading2: "Heading 2",
|
|
158
|
+
heading3: "Heading 3",
|
|
159
|
+
heading4: "Heading 4",
|
|
160
|
+
heading5: "Heading 5",
|
|
161
|
+
heading6: "Heading 6",
|
|
162
|
+
quote: "Quote",
|
|
163
|
+
preformatted: "Preformatted",
|
|
164
|
+
bold: "Bold",
|
|
165
|
+
italic: "Italic",
|
|
166
|
+
strike: "Strikethrough",
|
|
167
|
+
bulletList: "Bullet list",
|
|
168
|
+
numberedList: "Numbered list",
|
|
169
|
+
alignRight: "Align right",
|
|
170
|
+
alignCenter: "Align center",
|
|
171
|
+
alignLeft: "Align left",
|
|
172
|
+
alignImageRight: "Align image right",
|
|
173
|
+
alignImageCenter: "Align image center",
|
|
174
|
+
alignImageLeft: "Align image left",
|
|
175
|
+
rtl: "Right to left",
|
|
176
|
+
ltr: "Left to right",
|
|
177
|
+
indent: "Indent",
|
|
178
|
+
outdent: "Outdent",
|
|
179
|
+
insertLink: "Insert link",
|
|
180
|
+
insertImage: "Insert image",
|
|
181
|
+
horizontalRule: "Horizontal rule",
|
|
182
|
+
textColor: "Text color",
|
|
183
|
+
bgColor: "Highlight color",
|
|
184
|
+
applyCurrentColor: "Apply current color",
|
|
185
|
+
openPalette: "Open color palette",
|
|
186
|
+
noColor: "No color",
|
|
187
|
+
customColor: "Custom color",
|
|
188
|
+
pickCustomColor: "Pick custom color",
|
|
189
|
+
sourceMode: "Edit HTML",
|
|
190
|
+
visualMode: "Back to visual editor",
|
|
191
|
+
editorLabel: "Rich text editor",
|
|
192
|
+
sourceLabel: "HTML source editor",
|
|
193
|
+
close: "Close",
|
|
194
|
+
cancel: "Cancel",
|
|
195
|
+
save: "Save",
|
|
196
|
+
linkTitle: "Insert link",
|
|
197
|
+
linkUrl: "URL",
|
|
198
|
+
linkText: "Display text (optional)",
|
|
199
|
+
linkTextPlaceholder: "Link text",
|
|
200
|
+
linkSubmit: "Insert link",
|
|
201
|
+
linkUrlRequired: "Please enter a link URL.",
|
|
202
|
+
linkInvalid: "Invalid link.",
|
|
203
|
+
linkUnsafe: "The link URL is invalid or unsafe.",
|
|
204
|
+
imageTitle: "Insert image",
|
|
205
|
+
imageSubmit: "Insert image",
|
|
206
|
+
imageBusy: "Processing…",
|
|
207
|
+
imageUploadTab: "Upload file",
|
|
208
|
+
imageUrlTab: "From URL",
|
|
209
|
+
imageFile: "Image file",
|
|
210
|
+
imageUrl: "Image URL",
|
|
211
|
+
imageAlt: "Alt text",
|
|
212
|
+
imageAltPlaceholder: "Short image description",
|
|
213
|
+
imageHint: "Only jpg, png, gif, and webp — max 2 MB",
|
|
214
|
+
imagePickFile: "Please select an image file.",
|
|
215
|
+
imageInsertFailed: "Failed to insert image.",
|
|
216
|
+
imageUploadFailed: "Image upload failed.",
|
|
217
|
+
imageUnsafe: "The image URL is invalid or unsafe.",
|
|
218
|
+
altTitle: "Edit image alt text",
|
|
219
|
+
altLabel: "Alt text",
|
|
220
|
+
altPlaceholder: "Short description for accessibility and SEO",
|
|
221
|
+
altHint: "Shown when the image cannot load, and used by screen readers.",
|
|
222
|
+
editAlt: "Edit Alt",
|
|
223
|
+
editAltTitle: "Edit image alt text",
|
|
224
|
+
fileInvalid: "Invalid file.",
|
|
225
|
+
fileEmpty: "File is empty.",
|
|
226
|
+
fileTooLarge: (e) => `File size must not exceed ${e} MB.`,
|
|
227
|
+
fileBadExtension: "File extension is not allowed. Only jpg, png, gif, and webp.",
|
|
228
|
+
fileBadMime: "File type is not allowed.",
|
|
229
|
+
fileBadContent: "File content is not a valid image.",
|
|
230
|
+
fileMimeMismatch: "Declared file type does not match actual content.",
|
|
231
|
+
fileReadError: "Failed to read the file."
|
|
232
|
+
}, mt = {
|
|
233
|
+
placeholder: "متن خود را بنویسید…",
|
|
234
|
+
toolbar: "نوار ابزار ویرایشگر",
|
|
235
|
+
undo: "قبل (واگرد)",
|
|
236
|
+
redo: "بعد (بازگردانی)",
|
|
237
|
+
blockType: "نوع بلوک",
|
|
238
|
+
paragraph: "پاراگراف",
|
|
239
|
+
heading1: "عنوان ۱",
|
|
240
|
+
heading2: "عنوان ۲",
|
|
241
|
+
heading3: "عنوان ۳",
|
|
242
|
+
heading4: "عنوان ۴",
|
|
243
|
+
heading5: "عنوان ۵",
|
|
244
|
+
heading6: "عنوان ۶",
|
|
245
|
+
quote: "نقلقول",
|
|
246
|
+
preformatted: "پیشقالببندیشده",
|
|
247
|
+
bold: "ضخیم",
|
|
248
|
+
italic: "کج",
|
|
249
|
+
strike: "خطخورده",
|
|
250
|
+
bulletList: "فهرست نقطهای",
|
|
251
|
+
numberedList: "فهرست عددی",
|
|
252
|
+
alignRight: "راستچین",
|
|
253
|
+
alignCenter: "وسطچین",
|
|
254
|
+
alignLeft: "چپچین",
|
|
255
|
+
alignImageRight: "تراز راست تصویر",
|
|
256
|
+
alignImageCenter: "تراز وسط تصویر",
|
|
257
|
+
alignImageLeft: "تراز چپ تصویر",
|
|
258
|
+
rtl: "راست به چپ",
|
|
259
|
+
ltr: "چپ به راست",
|
|
260
|
+
indent: "فرورفتگی",
|
|
261
|
+
outdent: "بیرونآمدگی",
|
|
262
|
+
insertLink: "درج لینک",
|
|
263
|
+
insertImage: "درج تصویر",
|
|
264
|
+
horizontalRule: "خط افقی",
|
|
265
|
+
textColor: "رنگ متن",
|
|
266
|
+
bgColor: "رنگ پسزمینه",
|
|
267
|
+
applyCurrentColor: "اعمال رنگ فعلی",
|
|
268
|
+
openPalette: "باز کردن پالت رنگ",
|
|
269
|
+
noColor: "بدون رنگ",
|
|
270
|
+
customColor: "رنگ دلخواه",
|
|
271
|
+
pickCustomColor: "انتخاب رنگ دلخواه",
|
|
272
|
+
sourceMode: "ویرایش HTML",
|
|
273
|
+
visualMode: "بازگشت به حالت دیداری",
|
|
274
|
+
editorLabel: "ویرایشگر متن",
|
|
275
|
+
sourceLabel: "ویرایشگر کد HTML",
|
|
276
|
+
close: "بستن",
|
|
277
|
+
cancel: "انصراف",
|
|
278
|
+
save: "ذخیره",
|
|
279
|
+
linkTitle: "درج لینک",
|
|
280
|
+
linkUrl: "آدرس",
|
|
281
|
+
linkText: "متن نمایشی (اختیاری)",
|
|
282
|
+
linkTextPlaceholder: "متن لینک",
|
|
283
|
+
linkSubmit: "درج لینک",
|
|
284
|
+
linkUrlRequired: "آدرس لینک را وارد کنید.",
|
|
285
|
+
linkInvalid: "لینک نامعتبر است.",
|
|
286
|
+
linkUnsafe: "آدرس لینک نامعتبر یا ناامن است.",
|
|
287
|
+
imageTitle: "درج تصویر",
|
|
288
|
+
imageSubmit: "درج تصویر",
|
|
289
|
+
imageBusy: "در حال پردازش…",
|
|
290
|
+
imageUploadTab: "آپلود فایل",
|
|
291
|
+
imageUrlTab: "از آدرس",
|
|
292
|
+
imageFile: "فایل تصویر",
|
|
293
|
+
imageUrl: "آدرس تصویر",
|
|
294
|
+
imageAlt: "متن جایگزین",
|
|
295
|
+
imageAltPlaceholder: "توضیح کوتاه تصویر",
|
|
296
|
+
imageHint: "فقط jpg، png، gif و webp — حداکثر ۲ مگابایت",
|
|
297
|
+
imagePickFile: "یک فایل تصویر انتخاب کنید.",
|
|
298
|
+
imageInsertFailed: "درج تصویر ناموفق بود.",
|
|
299
|
+
imageUploadFailed: "آپلود تصویر ناموفق بود.",
|
|
300
|
+
imageUnsafe: "آدرس تصویر نامعتبر یا ناامن است.",
|
|
301
|
+
altTitle: "ویرایش متن جایگزین تصویر",
|
|
302
|
+
altLabel: "متن جایگزین (Alt)",
|
|
303
|
+
altPlaceholder: "توضیح کوتاه تصویر برای دسترسپذیری و SEO",
|
|
304
|
+
altHint: "این متن وقتی تصویر لود نشود نمایش داده میشود و برای خوانندههای صفحه مهم است.",
|
|
305
|
+
editAlt: "ویرایش Alt",
|
|
306
|
+
editAltTitle: "ویرایش متن جایگزین تصویر",
|
|
307
|
+
fileInvalid: "فایل نامعتبر است.",
|
|
308
|
+
fileEmpty: "فایل خالی است.",
|
|
309
|
+
fileTooLarge: (e) => `حجم فایل نباید بیشتر از ${e} مگابایت باشد.`,
|
|
310
|
+
fileBadExtension: "پسوند فایل مجاز نیست. فقط jpg، png، gif و webp.",
|
|
311
|
+
fileBadMime: "نوع فایل مجاز نیست.",
|
|
312
|
+
fileBadContent: "محتوای فایل تصویر معتبر نیست.",
|
|
313
|
+
fileMimeMismatch: "نوع اعلامشده فایل با محتوای واقعی همخوانی ندارد.",
|
|
314
|
+
fileReadError: "خواندن فایل با خطا مواجه شد."
|
|
315
|
+
}, pt = {
|
|
316
|
+
placeholder: "اكتب شيئاً…",
|
|
317
|
+
toolbar: "شريط أدوات المحرر",
|
|
318
|
+
undo: "تراجع",
|
|
319
|
+
redo: "إعادة",
|
|
320
|
+
blockType: "نوع الكتلة",
|
|
321
|
+
paragraph: "فقرة",
|
|
322
|
+
heading1: "عنوان 1",
|
|
323
|
+
heading2: "عنوان 2",
|
|
324
|
+
heading3: "عنوان 3",
|
|
325
|
+
heading4: "عنوان 4",
|
|
326
|
+
heading5: "عنوان 5",
|
|
327
|
+
heading6: "عنوان 6",
|
|
328
|
+
quote: "اقتباس",
|
|
329
|
+
preformatted: "نص منسق مسبقاً",
|
|
330
|
+
bold: "عريض",
|
|
331
|
+
italic: "مائل",
|
|
332
|
+
strike: "يتوسطه خط",
|
|
333
|
+
bulletList: "قائمة نقطية",
|
|
334
|
+
numberedList: "قائمة مرقمة",
|
|
335
|
+
alignRight: "محاذاة لليمين",
|
|
336
|
+
alignCenter: "محاذاة للوسط",
|
|
337
|
+
alignLeft: "محاذاة لليسار",
|
|
338
|
+
alignImageRight: "محاذاة الصورة لليمين",
|
|
339
|
+
alignImageCenter: "محاذاة الصورة للوسط",
|
|
340
|
+
alignImageLeft: "محاذاة الصورة لليسار",
|
|
341
|
+
rtl: "من اليمين إلى اليسار",
|
|
342
|
+
ltr: "من اليسار إلى اليمين",
|
|
343
|
+
indent: "زيادة المسافة البادئة",
|
|
344
|
+
outdent: "إنقاص المسافة البادئة",
|
|
345
|
+
insertLink: "إدراج رابط",
|
|
346
|
+
insertImage: "إدراج صورة",
|
|
347
|
+
horizontalRule: "خط أفقي",
|
|
348
|
+
textColor: "لون النص",
|
|
349
|
+
bgColor: "لون التمييز",
|
|
350
|
+
applyCurrentColor: "تطبيق اللون الحالي",
|
|
351
|
+
openPalette: "فتح لوحة الألوان",
|
|
352
|
+
noColor: "بدون لون",
|
|
353
|
+
customColor: "لون مخصص",
|
|
354
|
+
pickCustomColor: "اختيار لون مخصص",
|
|
355
|
+
sourceMode: "تحرير HTML",
|
|
356
|
+
visualMode: "العودة إلى المحرر المرئي",
|
|
357
|
+
editorLabel: "محرر النص",
|
|
358
|
+
sourceLabel: "محرر مصدر HTML",
|
|
359
|
+
close: "إغلاق",
|
|
360
|
+
cancel: "إلغاء",
|
|
361
|
+
save: "حفظ",
|
|
362
|
+
linkTitle: "إدراج رابط",
|
|
363
|
+
linkUrl: "العنوان",
|
|
364
|
+
linkText: "نص العرض (اختياري)",
|
|
365
|
+
linkTextPlaceholder: "نص الرابط",
|
|
366
|
+
linkSubmit: "إدراج الرابط",
|
|
367
|
+
linkUrlRequired: "يرجى إدخال عنوان الرابط.",
|
|
368
|
+
linkInvalid: "رابط غير صالح.",
|
|
369
|
+
linkUnsafe: "عنوان الرابط غير صالح أو غير آمن.",
|
|
370
|
+
imageTitle: "إدراج صورة",
|
|
371
|
+
imageSubmit: "إدراج الصورة",
|
|
372
|
+
imageBusy: "جارٍ المعالجة…",
|
|
373
|
+
imageUploadTab: "رفع ملف",
|
|
374
|
+
imageUrlTab: "من رابط",
|
|
375
|
+
imageFile: "ملف الصورة",
|
|
376
|
+
imageUrl: "رابط الصورة",
|
|
377
|
+
imageAlt: "النص البديل",
|
|
378
|
+
imageAltPlaceholder: "وصف قصير للصورة",
|
|
379
|
+
imageHint: "فقط jpg و png و gif و webp — بحد أقصى 2 ميجابايت",
|
|
380
|
+
imagePickFile: "يرجى اختيار ملف صورة.",
|
|
381
|
+
imageInsertFailed: "فشل إدراج الصورة.",
|
|
382
|
+
imageUploadFailed: "فشل رفع الصورة.",
|
|
383
|
+
imageUnsafe: "رابط الصورة غير صالح أو غير آمن.",
|
|
384
|
+
altTitle: "تحرير النص البديل للصورة",
|
|
385
|
+
altLabel: "النص البديل (Alt)",
|
|
386
|
+
altPlaceholder: "وصف قصير لإمكانية الوصول و SEO",
|
|
387
|
+
altHint: "يظهر عندما يتعذر تحميل الصورة، ويستخدمه قارئات الشاشة.",
|
|
388
|
+
editAlt: "تحرير Alt",
|
|
389
|
+
editAltTitle: "تحرير النص البديل للصورة",
|
|
390
|
+
fileInvalid: "ملف غير صالح.",
|
|
391
|
+
fileEmpty: "الملف فارغ.",
|
|
392
|
+
fileTooLarge: (e) => `يجب ألا يتجاوز حجم الملف ${e} ميجابايت.`,
|
|
393
|
+
fileBadExtension: "امتداد الملف غير مسموح. فقط jpg و png و gif و webp.",
|
|
394
|
+
fileBadMime: "نوع الملف غير مسموح.",
|
|
395
|
+
fileBadContent: "محتوى الملف ليس صورة صالحة.",
|
|
396
|
+
fileMimeMismatch: "نوع الملف المعلن لا يطابق المحتوى الفعلي.",
|
|
397
|
+
fileReadError: "فشل قراءة الملف."
|
|
398
|
+
}, He = { en: ht, fa: mt, ar: pt }, bt = /* @__PURE__ */ new Set(["fa", "ar"]);
|
|
399
|
+
function Le(e = "en") {
|
|
400
|
+
const t = String(e || "en").toLowerCase();
|
|
401
|
+
return He[t] ? t : "en";
|
|
402
|
+
}
|
|
403
|
+
function Oe(e = "en") {
|
|
404
|
+
return He[Le(e)];
|
|
405
|
+
}
|
|
406
|
+
function yt(e = "en") {
|
|
407
|
+
return bt.has(Le(e)) ? "rtl" : "ltr";
|
|
408
|
+
}
|
|
409
|
+
function kt(e) {
|
|
410
|
+
return [
|
|
411
|
+
{ value: "p", label: e.paragraph },
|
|
412
|
+
{ value: "h1", label: e.heading1 },
|
|
413
|
+
{ value: "h2", label: e.heading2 },
|
|
414
|
+
{ value: "h3", label: e.heading3 },
|
|
415
|
+
{ value: "h4", label: e.heading4 },
|
|
416
|
+
{ value: "h5", label: e.heading5 },
|
|
417
|
+
{ value: "h6", label: e.heading6 },
|
|
418
|
+
{ value: "blockquote", label: e.quote },
|
|
419
|
+
{ value: "pre", label: e.preformatted }
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
const vt = [
|
|
423
|
+
"#111827",
|
|
424
|
+
"#dc2626",
|
|
425
|
+
"#ea580c",
|
|
426
|
+
"#ca8a04",
|
|
427
|
+
"#16a34a",
|
|
428
|
+
"#2563eb",
|
|
429
|
+
"#7c3aed",
|
|
430
|
+
"#db2777",
|
|
431
|
+
"#ffffff"
|
|
432
|
+
], Lt = [
|
|
433
|
+
"transparent",
|
|
434
|
+
"#fef08a",
|
|
435
|
+
"#bbf7d0",
|
|
436
|
+
"#bfdbfe",
|
|
437
|
+
"#fecaca",
|
|
438
|
+
"#e9d5ff",
|
|
439
|
+
"#fed7aa",
|
|
440
|
+
"#e5e7eb",
|
|
441
|
+
"#111827"
|
|
442
|
+
];
|
|
443
|
+
function M({ label: e, active: t, disabled: n, onClick: r, children: l, className: a = "" }) {
|
|
444
|
+
return /* @__PURE__ */ i(
|
|
445
|
+
"button",
|
|
446
|
+
{
|
|
447
|
+
type: "button",
|
|
448
|
+
className: `te-tool${t ? " is-active" : ""}${a ? ` ${a}` : ""}`,
|
|
449
|
+
title: e,
|
|
450
|
+
"aria-label": e,
|
|
451
|
+
"aria-pressed": !!t,
|
|
452
|
+
disabled: n,
|
|
453
|
+
onMouseDown: (s) => {
|
|
454
|
+
s.preventDefault(), r == null || r(s);
|
|
455
|
+
},
|
|
456
|
+
children: l
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
function K() {
|
|
461
|
+
return /* @__PURE__ */ i("span", { className: "te-toolbar__divider", "aria-hidden": "true" });
|
|
462
|
+
}
|
|
463
|
+
function Se({
|
|
464
|
+
label: e,
|
|
465
|
+
icon: t,
|
|
466
|
+
colors: n,
|
|
467
|
+
value: r,
|
|
468
|
+
onChange: l,
|
|
469
|
+
onRememberSelection: a,
|
|
470
|
+
allowTransparent: s = !1,
|
|
471
|
+
disabled: c = !1,
|
|
472
|
+
t: f
|
|
473
|
+
}) {
|
|
474
|
+
const [v, m] = E(!1), [S, I] = E(null), T = F(null), x = F(!1), w = S ?? r, _ = !w || w === "transparent" ? s ? "repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 6px 6px" : "#111827" : w;
|
|
475
|
+
G(() => {
|
|
476
|
+
if (!v || c) {
|
|
477
|
+
I(null), c && m(!1);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
const h = (D) => {
|
|
481
|
+
var P;
|
|
482
|
+
x.current || (P = T.current) != null && P.contains(D.target) || m(!1);
|
|
483
|
+
}, p = (D) => {
|
|
484
|
+
D.key === "Escape" && !x.current && m(!1);
|
|
485
|
+
}, u = () => {
|
|
486
|
+
window.setTimeout(() => {
|
|
487
|
+
x.current = !1;
|
|
488
|
+
}, 50);
|
|
489
|
+
};
|
|
490
|
+
return document.addEventListener("mousedown", h), document.addEventListener("keydown", p), window.addEventListener("focus", u), () => {
|
|
491
|
+
document.removeEventListener("mousedown", h), document.removeEventListener("keydown", p), window.removeEventListener("focus", u);
|
|
492
|
+
};
|
|
493
|
+
}, [v, c]);
|
|
494
|
+
const k = (h, { close: p = !0 } = {}) => {
|
|
495
|
+
c || (a == null || a(), l(h), I(null), p && m(!1));
|
|
496
|
+
};
|
|
497
|
+
return /* @__PURE__ */ d("div", { className: `te-color${v ? " is-open" : ""}${c ? " is-disabled" : ""}`, ref: T, children: [
|
|
498
|
+
/* @__PURE__ */ d("div", { className: "te-color__split", children: [
|
|
499
|
+
/* @__PURE__ */ d(
|
|
500
|
+
"button",
|
|
501
|
+
{
|
|
502
|
+
type: "button",
|
|
503
|
+
className: "te-tool te-color__apply",
|
|
504
|
+
title: `${e} — ${f.applyCurrentColor}`,
|
|
505
|
+
"aria-label": `${e} — ${f.applyCurrentColor}`,
|
|
506
|
+
disabled: c,
|
|
507
|
+
onMouseDown: (h) => {
|
|
508
|
+
h.preventDefault(), !c && (a == null || a(), l(r));
|
|
509
|
+
},
|
|
510
|
+
children: [
|
|
511
|
+
/* @__PURE__ */ i("span", { className: "te-color__icon", children: t }),
|
|
512
|
+
/* @__PURE__ */ i(
|
|
513
|
+
"span",
|
|
514
|
+
{
|
|
515
|
+
className: "te-color__bar",
|
|
516
|
+
style: { background: _ },
|
|
517
|
+
"aria-hidden": "true"
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
]
|
|
521
|
+
}
|
|
522
|
+
),
|
|
523
|
+
/* @__PURE__ */ i(
|
|
524
|
+
"button",
|
|
525
|
+
{
|
|
526
|
+
type: "button",
|
|
527
|
+
className: `te-tool te-color__caret${v ? " is-active" : ""}`,
|
|
528
|
+
title: `${f.openPalette}: ${e}`,
|
|
529
|
+
"aria-label": `${f.openPalette}: ${e}`,
|
|
530
|
+
"aria-expanded": v,
|
|
531
|
+
"aria-haspopup": "true",
|
|
532
|
+
disabled: c,
|
|
533
|
+
onMouseDown: (h) => {
|
|
534
|
+
h.preventDefault(), !c && (a == null || a(), m((p) => !p));
|
|
535
|
+
},
|
|
536
|
+
children: C.chevronDown
|
|
537
|
+
}
|
|
538
|
+
)
|
|
539
|
+
] }),
|
|
540
|
+
v && !c ? /* @__PURE__ */ d(
|
|
541
|
+
"div",
|
|
542
|
+
{
|
|
543
|
+
className: "te-color__swatches",
|
|
544
|
+
role: "group",
|
|
545
|
+
"aria-label": e,
|
|
546
|
+
onMouseDown: (h) => h.stopPropagation(),
|
|
547
|
+
children: [
|
|
548
|
+
n.map((h) => /* @__PURE__ */ i(
|
|
549
|
+
"button",
|
|
550
|
+
{
|
|
551
|
+
type: "button",
|
|
552
|
+
className: `te-swatch${r === h ? " is-selected" : ""}`,
|
|
553
|
+
style: {
|
|
554
|
+
background: h === "transparent" ? "repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 8px 8px" : h,
|
|
555
|
+
borderColor: h === "#ffffff" ? "#d1d5db" : void 0
|
|
556
|
+
},
|
|
557
|
+
title: h === "transparent" ? f.noColor : h,
|
|
558
|
+
"aria-label": h === "transparent" ? f.noColor : h,
|
|
559
|
+
onMouseDown: (p) => {
|
|
560
|
+
p.preventDefault(), p.stopPropagation(), k(h);
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
h
|
|
564
|
+
)),
|
|
565
|
+
/* @__PURE__ */ i(
|
|
566
|
+
"label",
|
|
567
|
+
{
|
|
568
|
+
className: "te-swatch te-swatch--picker",
|
|
569
|
+
title: f.customColor,
|
|
570
|
+
onMouseDown: (h) => {
|
|
571
|
+
h.stopPropagation(), x.current = !0, a == null || a();
|
|
572
|
+
},
|
|
573
|
+
children: /* @__PURE__ */ i(
|
|
574
|
+
"input",
|
|
575
|
+
{
|
|
576
|
+
type: "color",
|
|
577
|
+
value: w && w !== "transparent" ? w : "#111827",
|
|
578
|
+
onMouseDown: (h) => {
|
|
579
|
+
h.stopPropagation(), x.current = !0;
|
|
580
|
+
},
|
|
581
|
+
onClick: (h) => {
|
|
582
|
+
h.stopPropagation(), x.current = !0;
|
|
583
|
+
},
|
|
584
|
+
onInput: (h) => {
|
|
585
|
+
I(h.target.value);
|
|
586
|
+
},
|
|
587
|
+
onChange: (h) => {
|
|
588
|
+
k(h.target.value, { close: !1 }), x.current = !1;
|
|
589
|
+
},
|
|
590
|
+
onBlur: () => {
|
|
591
|
+
window.setTimeout(() => {
|
|
592
|
+
x.current = !1, I(null);
|
|
593
|
+
}, 50);
|
|
594
|
+
},
|
|
595
|
+
"aria-label": `${f.pickCustomColor}: ${e}`
|
|
596
|
+
}
|
|
597
|
+
)
|
|
598
|
+
}
|
|
599
|
+
)
|
|
600
|
+
]
|
|
601
|
+
}
|
|
602
|
+
) : null
|
|
603
|
+
] });
|
|
604
|
+
}
|
|
605
|
+
function Ct({
|
|
606
|
+
t: e,
|
|
607
|
+
states: t,
|
|
608
|
+
canUndo: n,
|
|
609
|
+
canRedo: r,
|
|
610
|
+
onCommand: l,
|
|
611
|
+
onBlockChange: a,
|
|
612
|
+
onOpenLink: s,
|
|
613
|
+
onOpenImage: c,
|
|
614
|
+
onUndo: f,
|
|
615
|
+
onRedo: v,
|
|
616
|
+
onRememberSelection: m,
|
|
617
|
+
sourceMode: S = !1,
|
|
618
|
+
onToggleSource: I
|
|
619
|
+
}) {
|
|
620
|
+
const [T, x] = E("#111827"), [w, _] = E("#fef08a"), k = S, h = kt(e);
|
|
621
|
+
return /* @__PURE__ */ d("div", { className: "te-toolbar", role: "toolbar", "aria-label": e.toolbar, children: [
|
|
622
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group", children: [
|
|
623
|
+
/* @__PURE__ */ i(M, { label: e.undo, disabled: k || !n, onClick: f, children: C.undo }),
|
|
624
|
+
/* @__PURE__ */ i(M, { label: e.redo, disabled: k || !r, onClick: v, children: C.redo })
|
|
625
|
+
] }),
|
|
626
|
+
/* @__PURE__ */ i(K, {}),
|
|
627
|
+
/* @__PURE__ */ i("div", { className: "te-toolbar__group", children: /* @__PURE__ */ d("label", { className: "te-select-wrap", children: [
|
|
628
|
+
/* @__PURE__ */ i("span", { className: "te-sr-only", children: e.blockType }),
|
|
629
|
+
/* @__PURE__ */ i(
|
|
630
|
+
"select",
|
|
631
|
+
{
|
|
632
|
+
className: "te-select",
|
|
633
|
+
value: t.format || "p",
|
|
634
|
+
disabled: k,
|
|
635
|
+
onChange: (p) => a(p.target.value),
|
|
636
|
+
onMouseDown: (p) => {
|
|
637
|
+
p.stopPropagation(), m == null || m();
|
|
638
|
+
},
|
|
639
|
+
children: h.map((p) => /* @__PURE__ */ i("option", { value: p.value, children: p.label }, p.value))
|
|
640
|
+
}
|
|
641
|
+
)
|
|
642
|
+
] }) }),
|
|
643
|
+
/* @__PURE__ */ i(K, {}),
|
|
644
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group", children: [
|
|
645
|
+
/* @__PURE__ */ i(
|
|
646
|
+
M,
|
|
647
|
+
{
|
|
648
|
+
label: e.bold,
|
|
649
|
+
active: t.bold,
|
|
650
|
+
disabled: k,
|
|
651
|
+
onClick: () => l("bold"),
|
|
652
|
+
children: C.bold
|
|
653
|
+
}
|
|
654
|
+
),
|
|
655
|
+
/* @__PURE__ */ i(
|
|
656
|
+
M,
|
|
657
|
+
{
|
|
658
|
+
label: e.italic,
|
|
659
|
+
active: t.italic,
|
|
660
|
+
disabled: k,
|
|
661
|
+
onClick: () => l("italic"),
|
|
662
|
+
children: C.italic
|
|
663
|
+
}
|
|
664
|
+
),
|
|
665
|
+
/* @__PURE__ */ i(
|
|
666
|
+
M,
|
|
667
|
+
{
|
|
668
|
+
label: e.strike,
|
|
669
|
+
active: t.strikeThrough,
|
|
670
|
+
disabled: k,
|
|
671
|
+
onClick: () => l("strikeThrough"),
|
|
672
|
+
children: C.strike
|
|
673
|
+
}
|
|
674
|
+
)
|
|
675
|
+
] }),
|
|
676
|
+
/* @__PURE__ */ i(K, {}),
|
|
677
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group", children: [
|
|
678
|
+
/* @__PURE__ */ i(
|
|
679
|
+
M,
|
|
680
|
+
{
|
|
681
|
+
label: e.bulletList,
|
|
682
|
+
active: t.unorderedList,
|
|
683
|
+
disabled: k,
|
|
684
|
+
onClick: () => l("insertUnorderedList"),
|
|
685
|
+
children: C.ul
|
|
686
|
+
}
|
|
687
|
+
),
|
|
688
|
+
/* @__PURE__ */ i(
|
|
689
|
+
M,
|
|
690
|
+
{
|
|
691
|
+
label: e.numberedList,
|
|
692
|
+
active: t.orderedList,
|
|
693
|
+
disabled: k,
|
|
694
|
+
onClick: () => l("insertOrderedList"),
|
|
695
|
+
children: C.ol
|
|
696
|
+
}
|
|
697
|
+
),
|
|
698
|
+
/* @__PURE__ */ i(
|
|
699
|
+
M,
|
|
700
|
+
{
|
|
701
|
+
label: e.quote,
|
|
702
|
+
active: t.format === "blockquote",
|
|
703
|
+
disabled: k,
|
|
704
|
+
onClick: () => a(t.format === "blockquote" ? "p" : "blockquote"),
|
|
705
|
+
children: C.quote
|
|
706
|
+
}
|
|
707
|
+
)
|
|
708
|
+
] }),
|
|
709
|
+
/* @__PURE__ */ i(K, {}),
|
|
710
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group", children: [
|
|
711
|
+
/* @__PURE__ */ i(
|
|
712
|
+
M,
|
|
713
|
+
{
|
|
714
|
+
label: t.hasSelectedImage ? e.alignImageRight : e.alignRight,
|
|
715
|
+
active: t.justifyRight,
|
|
716
|
+
disabled: k,
|
|
717
|
+
onClick: () => l("justifyRight"),
|
|
718
|
+
children: C.alignRight
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
/* @__PURE__ */ i(
|
|
722
|
+
M,
|
|
723
|
+
{
|
|
724
|
+
label: t.hasSelectedImage ? e.alignImageCenter : e.alignCenter,
|
|
725
|
+
active: t.justifyCenter,
|
|
726
|
+
disabled: k,
|
|
727
|
+
onClick: () => l("justifyCenter"),
|
|
728
|
+
children: C.alignCenter
|
|
729
|
+
}
|
|
730
|
+
),
|
|
731
|
+
/* @__PURE__ */ i(
|
|
732
|
+
M,
|
|
733
|
+
{
|
|
734
|
+
label: t.hasSelectedImage ? e.alignImageLeft : e.alignLeft,
|
|
735
|
+
active: t.justifyLeft,
|
|
736
|
+
disabled: k,
|
|
737
|
+
onClick: () => l("justifyLeft"),
|
|
738
|
+
children: C.alignLeft
|
|
739
|
+
}
|
|
740
|
+
)
|
|
741
|
+
] }),
|
|
742
|
+
/* @__PURE__ */ i(K, {}),
|
|
743
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group", children: [
|
|
744
|
+
/* @__PURE__ */ i(M, { label: e.rtl, disabled: k, onClick: () => l("rtl"), children: C.rtl }),
|
|
745
|
+
/* @__PURE__ */ i(M, { label: e.ltr, disabled: k, onClick: () => l("ltr"), children: C.ltr })
|
|
746
|
+
] }),
|
|
747
|
+
/* @__PURE__ */ i(K, {}),
|
|
748
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group", children: [
|
|
749
|
+
/* @__PURE__ */ i(
|
|
750
|
+
M,
|
|
751
|
+
{
|
|
752
|
+
label: e.indent,
|
|
753
|
+
className: "te-tool--indent",
|
|
754
|
+
disabled: k,
|
|
755
|
+
onClick: () => l("indent"),
|
|
756
|
+
children: C.indent
|
|
757
|
+
}
|
|
758
|
+
),
|
|
759
|
+
/* @__PURE__ */ i(
|
|
760
|
+
M,
|
|
761
|
+
{
|
|
762
|
+
label: e.outdent,
|
|
763
|
+
className: "te-tool--outdent",
|
|
764
|
+
disabled: k,
|
|
765
|
+
onClick: () => l("outdent"),
|
|
766
|
+
children: C.outdent
|
|
767
|
+
}
|
|
768
|
+
)
|
|
769
|
+
] }),
|
|
770
|
+
/* @__PURE__ */ i(K, {}),
|
|
771
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group", children: [
|
|
772
|
+
/* @__PURE__ */ i(M, { label: e.insertLink, disabled: k, onClick: s, children: C.link }),
|
|
773
|
+
/* @__PURE__ */ i(M, { label: e.insertImage, disabled: k, onClick: c, children: C.image }),
|
|
774
|
+
/* @__PURE__ */ i(
|
|
775
|
+
M,
|
|
776
|
+
{
|
|
777
|
+
label: e.horizontalRule,
|
|
778
|
+
disabled: k,
|
|
779
|
+
onClick: () => l("insertHorizontalRule"),
|
|
780
|
+
children: C.hr
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
] }),
|
|
784
|
+
/* @__PURE__ */ i(K, {}),
|
|
785
|
+
/* @__PURE__ */ d("div", { className: "te-toolbar__group te-toolbar__colors", children: [
|
|
786
|
+
/* @__PURE__ */ i(
|
|
787
|
+
Se,
|
|
788
|
+
{
|
|
789
|
+
label: e.textColor,
|
|
790
|
+
icon: C.textColor,
|
|
791
|
+
colors: vt,
|
|
792
|
+
value: T,
|
|
793
|
+
disabled: k,
|
|
794
|
+
t: e,
|
|
795
|
+
onRememberSelection: m,
|
|
796
|
+
onChange: (p) => {
|
|
797
|
+
x(p), l("foreColor", p);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
),
|
|
801
|
+
/* @__PURE__ */ i(
|
|
802
|
+
Se,
|
|
803
|
+
{
|
|
804
|
+
label: e.bgColor,
|
|
805
|
+
icon: C.bgColor,
|
|
806
|
+
colors: Lt,
|
|
807
|
+
value: w,
|
|
808
|
+
allowTransparent: !0,
|
|
809
|
+
disabled: k,
|
|
810
|
+
t: e,
|
|
811
|
+
onRememberSelection: m,
|
|
812
|
+
onChange: (p) => {
|
|
813
|
+
_(p), l("hiliteColor", p);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
)
|
|
817
|
+
] }),
|
|
818
|
+
/* @__PURE__ */ i(K, {}),
|
|
819
|
+
/* @__PURE__ */ i("div", { className: "te-toolbar__group", children: /* @__PURE__ */ i(
|
|
820
|
+
M,
|
|
821
|
+
{
|
|
822
|
+
label: S ? e.visualMode : e.sourceMode,
|
|
823
|
+
active: S,
|
|
824
|
+
onClick: I,
|
|
825
|
+
children: C.code
|
|
826
|
+
}
|
|
827
|
+
) })
|
|
828
|
+
] });
|
|
829
|
+
}
|
|
830
|
+
function Ce({ open: e, title: t, onClose: n, children: r, footer: l, closeLabel: a = "Close" }) {
|
|
831
|
+
const s = ut(), c = F(null);
|
|
832
|
+
return G(() => {
|
|
833
|
+
var m, S;
|
|
834
|
+
if (!e) return;
|
|
835
|
+
const f = (I) => {
|
|
836
|
+
I.key === "Escape" && (n == null || n());
|
|
837
|
+
};
|
|
838
|
+
document.addEventListener("keydown", f);
|
|
839
|
+
const v = document.activeElement;
|
|
840
|
+
return (S = (m = c.current) == null ? void 0 : m.querySelector("input,button,textarea,select")) == null || S.focus(), () => {
|
|
841
|
+
document.removeEventListener("keydown", f), v && typeof v.focus == "function" && v.focus();
|
|
842
|
+
};
|
|
843
|
+
}, [e, n]), e ? /* @__PURE__ */ i("div", { className: "te-modal-backdrop", role: "presentation", onMouseDown: n, children: /* @__PURE__ */ d(
|
|
844
|
+
"div",
|
|
845
|
+
{
|
|
846
|
+
className: "te-modal",
|
|
847
|
+
role: "dialog",
|
|
848
|
+
"aria-modal": "true",
|
|
849
|
+
"aria-labelledby": s,
|
|
850
|
+
ref: c,
|
|
851
|
+
onMouseDown: (f) => f.stopPropagation(),
|
|
852
|
+
children: [
|
|
853
|
+
/* @__PURE__ */ d("div", { className: "te-modal__header", children: [
|
|
854
|
+
/* @__PURE__ */ i("h3", { id: s, children: t }),
|
|
855
|
+
/* @__PURE__ */ i(
|
|
856
|
+
"button",
|
|
857
|
+
{
|
|
858
|
+
type: "button",
|
|
859
|
+
className: "te-modal__close",
|
|
860
|
+
onClick: n,
|
|
861
|
+
"aria-label": a,
|
|
862
|
+
children: C.close
|
|
863
|
+
}
|
|
864
|
+
)
|
|
865
|
+
] }),
|
|
866
|
+
/* @__PURE__ */ i("div", { className: "te-modal__body", children: r }),
|
|
867
|
+
l ? /* @__PURE__ */ i("div", { className: "te-modal__footer", children: l }) : null
|
|
868
|
+
]
|
|
869
|
+
}
|
|
870
|
+
) }) : null;
|
|
871
|
+
}
|
|
872
|
+
function Et({
|
|
873
|
+
open: e,
|
|
874
|
+
onClose: t,
|
|
875
|
+
onSubmit: n,
|
|
876
|
+
initialUrl: r = "",
|
|
877
|
+
initialText: l = "",
|
|
878
|
+
t: a
|
|
879
|
+
}) {
|
|
880
|
+
const [s, c] = E(r), [f, v] = E(l), [m, S] = E("");
|
|
881
|
+
G(() => {
|
|
882
|
+
e && (c(r), v(l), S(""));
|
|
883
|
+
}, [e, r, l]);
|
|
884
|
+
const I = (T) => {
|
|
885
|
+
T.preventDefault();
|
|
886
|
+
const x = s.trim();
|
|
887
|
+
if (!x) {
|
|
888
|
+
S(a.linkUrlRequired);
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
try {
|
|
892
|
+
n({ url: x, text: f.trim() }), t();
|
|
893
|
+
} catch (w) {
|
|
894
|
+
S(w.message || a.linkInvalid);
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
return /* @__PURE__ */ i(
|
|
898
|
+
Ce,
|
|
899
|
+
{
|
|
900
|
+
open: e,
|
|
901
|
+
title: a.linkTitle,
|
|
902
|
+
onClose: t,
|
|
903
|
+
closeLabel: a.close,
|
|
904
|
+
footer: /* @__PURE__ */ d(ve, { children: [
|
|
905
|
+
/* @__PURE__ */ i("button", { type: "button", className: "te-btn te-btn--ghost", onClick: t, children: a.cancel }),
|
|
906
|
+
/* @__PURE__ */ i("button", { type: "submit", form: "te-link-form", className: "te-btn te-btn--primary", children: a.linkSubmit })
|
|
907
|
+
] }),
|
|
908
|
+
children: /* @__PURE__ */ d("form", { id: "te-link-form", onSubmit: I, className: "te-form", children: [
|
|
909
|
+
/* @__PURE__ */ d("label", { className: "te-field", children: [
|
|
910
|
+
/* @__PURE__ */ i("span", { children: a.linkUrl }),
|
|
911
|
+
/* @__PURE__ */ i(
|
|
912
|
+
"input",
|
|
913
|
+
{
|
|
914
|
+
type: "url",
|
|
915
|
+
dir: "ltr",
|
|
916
|
+
placeholder: "https://example.com",
|
|
917
|
+
value: s,
|
|
918
|
+
onChange: (T) => c(T.target.value),
|
|
919
|
+
required: !0
|
|
920
|
+
}
|
|
921
|
+
)
|
|
922
|
+
] }),
|
|
923
|
+
/* @__PURE__ */ d("label", { className: "te-field", children: [
|
|
924
|
+
/* @__PURE__ */ i("span", { children: a.linkText }),
|
|
925
|
+
/* @__PURE__ */ i(
|
|
926
|
+
"input",
|
|
927
|
+
{
|
|
928
|
+
type: "text",
|
|
929
|
+
placeholder: a.linkTextPlaceholder,
|
|
930
|
+
value: f,
|
|
931
|
+
onChange: (T) => v(T.target.value)
|
|
932
|
+
}
|
|
933
|
+
)
|
|
934
|
+
] }),
|
|
935
|
+
m ? /* @__PURE__ */ i("p", { className: "te-error", children: m }) : null
|
|
936
|
+
] })
|
|
937
|
+
}
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
function At({
|
|
941
|
+
open: e,
|
|
942
|
+
onClose: t,
|
|
943
|
+
onSubmitUrl: n,
|
|
944
|
+
onSubmitFile: r,
|
|
945
|
+
accept: l = "image/jpeg,image/png,image/gif,image/webp",
|
|
946
|
+
t: a
|
|
947
|
+
}) {
|
|
948
|
+
const [s, c] = E("file"), [f, v] = E(""), [m, S] = E(""), [I, T] = E(""), [x, w] = E(!1), _ = F(null);
|
|
949
|
+
G(() => {
|
|
950
|
+
e && (c("file"), v(""), S(""), T(""), w(!1), _.current && (_.current.value = ""));
|
|
951
|
+
}, [e]);
|
|
952
|
+
const k = async (p) => {
|
|
953
|
+
p.preventDefault(), T(""), w(!0);
|
|
954
|
+
try {
|
|
955
|
+
await n({ url: f.trim(), alt: m.trim() }), t();
|
|
956
|
+
} catch (u) {
|
|
957
|
+
T(u.message || a.imageInsertFailed);
|
|
958
|
+
} finally {
|
|
959
|
+
w(!1);
|
|
960
|
+
}
|
|
961
|
+
}, h = async (p) => {
|
|
962
|
+
var D, P;
|
|
963
|
+
p.preventDefault();
|
|
964
|
+
const u = (P = (D = _.current) == null ? void 0 : D.files) == null ? void 0 : P[0];
|
|
965
|
+
if (!u) {
|
|
966
|
+
T(a.imagePickFile);
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
T(""), w(!0);
|
|
970
|
+
try {
|
|
971
|
+
await r({ file: u, alt: m.trim() }), t();
|
|
972
|
+
} catch (q) {
|
|
973
|
+
T(q.message || a.imageUploadFailed);
|
|
974
|
+
} finally {
|
|
975
|
+
w(!1);
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
return /* @__PURE__ */ d(
|
|
979
|
+
Ce,
|
|
980
|
+
{
|
|
981
|
+
open: e,
|
|
982
|
+
title: a.imageTitle,
|
|
983
|
+
onClose: t,
|
|
984
|
+
closeLabel: a.close,
|
|
985
|
+
footer: /* @__PURE__ */ d(ve, { children: [
|
|
986
|
+
/* @__PURE__ */ i("button", { type: "button", className: "te-btn te-btn--ghost", onClick: t, disabled: x, children: a.cancel }),
|
|
987
|
+
/* @__PURE__ */ i(
|
|
988
|
+
"button",
|
|
989
|
+
{
|
|
990
|
+
type: "submit",
|
|
991
|
+
form: s === "file" ? "te-image-file-form" : "te-image-url-form",
|
|
992
|
+
className: "te-btn te-btn--primary",
|
|
993
|
+
disabled: x,
|
|
994
|
+
children: x ? a.imageBusy : a.imageSubmit
|
|
995
|
+
}
|
|
996
|
+
)
|
|
997
|
+
] }),
|
|
998
|
+
children: [
|
|
999
|
+
/* @__PURE__ */ d("div", { className: "te-tabs", role: "tablist", children: [
|
|
1000
|
+
/* @__PURE__ */ i(
|
|
1001
|
+
"button",
|
|
1002
|
+
{
|
|
1003
|
+
type: "button",
|
|
1004
|
+
role: "tab",
|
|
1005
|
+
"aria-selected": s === "file",
|
|
1006
|
+
className: s === "file" ? "is-active" : "",
|
|
1007
|
+
onClick: () => c("file"),
|
|
1008
|
+
children: a.imageUploadTab
|
|
1009
|
+
}
|
|
1010
|
+
),
|
|
1011
|
+
/* @__PURE__ */ i(
|
|
1012
|
+
"button",
|
|
1013
|
+
{
|
|
1014
|
+
type: "button",
|
|
1015
|
+
role: "tab",
|
|
1016
|
+
"aria-selected": s === "url",
|
|
1017
|
+
className: s === "url" ? "is-active" : "",
|
|
1018
|
+
onClick: () => c("url"),
|
|
1019
|
+
children: a.imageUrlTab
|
|
1020
|
+
}
|
|
1021
|
+
)
|
|
1022
|
+
] }),
|
|
1023
|
+
s === "file" ? /* @__PURE__ */ d("form", { id: "te-image-file-form", onSubmit: h, className: "te-form", children: [
|
|
1024
|
+
/* @__PURE__ */ d("label", { className: "te-field", children: [
|
|
1025
|
+
/* @__PURE__ */ i("span", { children: a.imageFile }),
|
|
1026
|
+
/* @__PURE__ */ i("input", { ref: _, type: "file", accept: l })
|
|
1027
|
+
] }),
|
|
1028
|
+
/* @__PURE__ */ d("label", { className: "te-field", children: [
|
|
1029
|
+
/* @__PURE__ */ i("span", { children: a.imageAlt }),
|
|
1030
|
+
/* @__PURE__ */ i(
|
|
1031
|
+
"input",
|
|
1032
|
+
{
|
|
1033
|
+
type: "text",
|
|
1034
|
+
value: m,
|
|
1035
|
+
onChange: (p) => S(p.target.value),
|
|
1036
|
+
placeholder: a.imageAltPlaceholder
|
|
1037
|
+
}
|
|
1038
|
+
)
|
|
1039
|
+
] }),
|
|
1040
|
+
/* @__PURE__ */ i("p", { className: "te-hint", children: a.imageHint }),
|
|
1041
|
+
I ? /* @__PURE__ */ i("p", { className: "te-error", children: I }) : null
|
|
1042
|
+
] }) : /* @__PURE__ */ d("form", { id: "te-image-url-form", onSubmit: k, className: "te-form", children: [
|
|
1043
|
+
/* @__PURE__ */ d("label", { className: "te-field", children: [
|
|
1044
|
+
/* @__PURE__ */ i("span", { children: a.imageUrl }),
|
|
1045
|
+
/* @__PURE__ */ i(
|
|
1046
|
+
"input",
|
|
1047
|
+
{
|
|
1048
|
+
type: "url",
|
|
1049
|
+
dir: "ltr",
|
|
1050
|
+
placeholder: "https://...",
|
|
1051
|
+
value: f,
|
|
1052
|
+
onChange: (p) => v(p.target.value),
|
|
1053
|
+
required: !0
|
|
1054
|
+
}
|
|
1055
|
+
)
|
|
1056
|
+
] }),
|
|
1057
|
+
/* @__PURE__ */ d("label", { className: "te-field", children: [
|
|
1058
|
+
/* @__PURE__ */ i("span", { children: a.imageAlt }),
|
|
1059
|
+
/* @__PURE__ */ i(
|
|
1060
|
+
"input",
|
|
1061
|
+
{
|
|
1062
|
+
type: "text",
|
|
1063
|
+
value: m,
|
|
1064
|
+
onChange: (p) => S(p.target.value),
|
|
1065
|
+
placeholder: a.imageAltPlaceholder
|
|
1066
|
+
}
|
|
1067
|
+
)
|
|
1068
|
+
] }),
|
|
1069
|
+
I ? /* @__PURE__ */ i("p", { className: "te-error", children: I }) : null
|
|
1070
|
+
] })
|
|
1071
|
+
]
|
|
1072
|
+
}
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
function wt({ open: e, onClose: t, onSubmit: n, initialAlt: r = "", t: l }) {
|
|
1076
|
+
const [a, s] = E(r);
|
|
1077
|
+
G(() => {
|
|
1078
|
+
e && s(r);
|
|
1079
|
+
}, [e, r]);
|
|
1080
|
+
const c = (f) => {
|
|
1081
|
+
f.preventDefault(), n({ alt: a.trim() }), t();
|
|
1082
|
+
};
|
|
1083
|
+
return /* @__PURE__ */ i(
|
|
1084
|
+
Ce,
|
|
1085
|
+
{
|
|
1086
|
+
open: e,
|
|
1087
|
+
title: l.altTitle,
|
|
1088
|
+
onClose: t,
|
|
1089
|
+
closeLabel: l.close,
|
|
1090
|
+
footer: /* @__PURE__ */ d(ve, { children: [
|
|
1091
|
+
/* @__PURE__ */ i("button", { type: "button", className: "te-btn te-btn--ghost", onClick: t, children: l.cancel }),
|
|
1092
|
+
/* @__PURE__ */ i("button", { type: "submit", form: "te-image-alt-form", className: "te-btn te-btn--primary", children: l.save })
|
|
1093
|
+
] }),
|
|
1094
|
+
children: /* @__PURE__ */ d("form", { id: "te-image-alt-form", onSubmit: c, className: "te-form", children: [
|
|
1095
|
+
/* @__PURE__ */ d("label", { className: "te-field", children: [
|
|
1096
|
+
/* @__PURE__ */ i("span", { children: l.altLabel }),
|
|
1097
|
+
/* @__PURE__ */ i(
|
|
1098
|
+
"input",
|
|
1099
|
+
{
|
|
1100
|
+
type: "text",
|
|
1101
|
+
value: a,
|
|
1102
|
+
onChange: (f) => s(f.target.value),
|
|
1103
|
+
placeholder: l.altPlaceholder
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
] }),
|
|
1107
|
+
/* @__PURE__ */ i("p", { className: "te-hint", children: l.altHint })
|
|
1108
|
+
] })
|
|
1109
|
+
}
|
|
1110
|
+
);
|
|
1111
|
+
}
|
|
1112
|
+
const Nt = [
|
|
1113
|
+
"p",
|
|
1114
|
+
"br",
|
|
1115
|
+
"div",
|
|
1116
|
+
"span",
|
|
1117
|
+
"h1",
|
|
1118
|
+
"h2",
|
|
1119
|
+
"h3",
|
|
1120
|
+
"h4",
|
|
1121
|
+
"h5",
|
|
1122
|
+
"h6",
|
|
1123
|
+
"ul",
|
|
1124
|
+
"ol",
|
|
1125
|
+
"li",
|
|
1126
|
+
"strong",
|
|
1127
|
+
"b",
|
|
1128
|
+
"em",
|
|
1129
|
+
"i",
|
|
1130
|
+
"s",
|
|
1131
|
+
"strike",
|
|
1132
|
+
"del",
|
|
1133
|
+
"blockquote",
|
|
1134
|
+
"pre",
|
|
1135
|
+
"a",
|
|
1136
|
+
"img",
|
|
1137
|
+
"hr",
|
|
1138
|
+
"u",
|
|
1139
|
+
"font"
|
|
1140
|
+
], Tt = [
|
|
1141
|
+
"href",
|
|
1142
|
+
"target",
|
|
1143
|
+
"rel",
|
|
1144
|
+
"src",
|
|
1145
|
+
"alt",
|
|
1146
|
+
"title",
|
|
1147
|
+
"width",
|
|
1148
|
+
"height",
|
|
1149
|
+
"style",
|
|
1150
|
+
"dir",
|
|
1151
|
+
"class",
|
|
1152
|
+
"color",
|
|
1153
|
+
"face",
|
|
1154
|
+
"size",
|
|
1155
|
+
"contenteditable",
|
|
1156
|
+
"data-align",
|
|
1157
|
+
"loading",
|
|
1158
|
+
"draggable"
|
|
1159
|
+
], xt = /^(https?:|mailto:|tel:|blob:)/i, Mt = /^(https?:|blob:|data:image\/(png|jpeg|jpg|gif|webp);base64,)/i;
|
|
1160
|
+
function ue(e, t = !1) {
|
|
1161
|
+
if (!e || typeof e != "string") return !1;
|
|
1162
|
+
const n = e.trim();
|
|
1163
|
+
return n.startsWith("javascript:") || n.startsWith("vbscript:") ? !1 : n.startsWith("#") || n.startsWith("/") ? !0 : t ? Mt.test(n) : xt.test(n) || n.startsWith("/");
|
|
1164
|
+
}
|
|
1165
|
+
function St(e) {
|
|
1166
|
+
if (!e || typeof e != "string") return "";
|
|
1167
|
+
const t = /* @__PURE__ */ new Set([
|
|
1168
|
+
"color",
|
|
1169
|
+
"background-color",
|
|
1170
|
+
"text-align",
|
|
1171
|
+
"direction",
|
|
1172
|
+
"margin",
|
|
1173
|
+
"margin-top",
|
|
1174
|
+
"margin-right",
|
|
1175
|
+
"margin-bottom",
|
|
1176
|
+
"margin-left",
|
|
1177
|
+
"margin-inline-start",
|
|
1178
|
+
"margin-inline-end",
|
|
1179
|
+
"padding-right",
|
|
1180
|
+
"padding-left",
|
|
1181
|
+
"padding-inline-start",
|
|
1182
|
+
"padding-inline-end",
|
|
1183
|
+
"text-indent",
|
|
1184
|
+
"font-weight",
|
|
1185
|
+
"font-style",
|
|
1186
|
+
"text-decoration",
|
|
1187
|
+
"text-decoration-line",
|
|
1188
|
+
"display",
|
|
1189
|
+
"float",
|
|
1190
|
+
"max-width",
|
|
1191
|
+
"width",
|
|
1192
|
+
"height",
|
|
1193
|
+
"box-sizing"
|
|
1194
|
+
]);
|
|
1195
|
+
return e.split(";").map((n) => n.trim()).filter(Boolean).map((n) => {
|
|
1196
|
+
const r = n.indexOf(":");
|
|
1197
|
+
if (r === -1) return null;
|
|
1198
|
+
const l = n.slice(0, r).trim().toLowerCase(), a = n.slice(r + 1).trim();
|
|
1199
|
+
return !t.has(l) || /expression|url\s*\(|javascript|import/i.test(a) ? null : `${l}: ${a}`;
|
|
1200
|
+
}).filter(Boolean).join("; ");
|
|
1201
|
+
}
|
|
1202
|
+
function W(e) {
|
|
1203
|
+
if (!e) return "";
|
|
1204
|
+
const t = gt.sanitize(e, {
|
|
1205
|
+
ALLOWED_TAGS: Nt,
|
|
1206
|
+
ALLOWED_ATTR: Tt,
|
|
1207
|
+
ALLOW_DATA_ATTR: !1,
|
|
1208
|
+
FORBID_TAGS: ["script", "iframe", "object", "embed", "form", "input", "style"],
|
|
1209
|
+
FORBID_ATTR: [
|
|
1210
|
+
"onerror",
|
|
1211
|
+
"onload",
|
|
1212
|
+
"onclick",
|
|
1213
|
+
"onmouseover",
|
|
1214
|
+
"onfocus",
|
|
1215
|
+
"onblur",
|
|
1216
|
+
"onchange",
|
|
1217
|
+
"onsubmit"
|
|
1218
|
+
]
|
|
1219
|
+
});
|
|
1220
|
+
if (typeof document > "u") return t;
|
|
1221
|
+
const n = document.createElement("div");
|
|
1222
|
+
return n.innerHTML = t, n.querySelectorAll("font").forEach((r) => {
|
|
1223
|
+
const l = document.createElement("span"), a = r.getAttribute("color");
|
|
1224
|
+
for (a && (l.style.color = a); r.firstChild; ) l.appendChild(r.firstChild);
|
|
1225
|
+
r.replaceWith(l);
|
|
1226
|
+
}), n.querySelectorAll("a").forEach((r) => {
|
|
1227
|
+
const l = r.getAttribute("href") || "";
|
|
1228
|
+
ue(l, !1) ? (r.setAttribute("rel", "noopener noreferrer"), /^https?:/i.test(l) && r.setAttribute("target", "_blank")) : r.removeAttribute("href");
|
|
1229
|
+
}), n.querySelectorAll("img").forEach((r) => {
|
|
1230
|
+
var a, s, c, f;
|
|
1231
|
+
const l = r.getAttribute("src") || "";
|
|
1232
|
+
if (!ue(l, !0)) {
|
|
1233
|
+
r.remove();
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
if (r.removeAttribute("onerror"), r.removeAttribute("onload"), !((s = (a = r.parentElement) == null ? void 0 : a.classList) != null && s.contains("te-figure"))) {
|
|
1237
|
+
const v = document.createElement("div");
|
|
1238
|
+
v.className = "te-figure", v.setAttribute("contenteditable", "false");
|
|
1239
|
+
const m = r.style.textAlign || r.getAttribute("data-align") || ((f = (c = r.parentElement) == null ? void 0 : c.style) == null ? void 0 : f.textAlign) || "center";
|
|
1240
|
+
v.setAttribute("data-align", m), v.style.textAlign = m, r.replaceWith(v), v.appendChild(r);
|
|
1241
|
+
}
|
|
1242
|
+
}), n.querySelectorAll(".te-figure").forEach((r) => {
|
|
1243
|
+
r.setAttribute("contenteditable", "false"), r.getAttribute("data-align") || r.setAttribute("data-align", r.style.textAlign || "center"), r.querySelectorAll(".te-figure__alt-btn, button").forEach((l) => l.remove()), r.classList.remove("is-selected");
|
|
1244
|
+
}), n.querySelectorAll("img.is-selected").forEach((r) => {
|
|
1245
|
+
r.classList.remove("is-selected");
|
|
1246
|
+
}), n.querySelectorAll("[style]").forEach((r) => {
|
|
1247
|
+
const l = St(r.getAttribute("style"));
|
|
1248
|
+
l ? r.setAttribute("style", l) : r.removeAttribute("style");
|
|
1249
|
+
}), le(n), n.innerHTML;
|
|
1250
|
+
}
|
|
1251
|
+
function me(e) {
|
|
1252
|
+
const t = e.parentNode;
|
|
1253
|
+
if (t) {
|
|
1254
|
+
for (; e.firstChild; ) t.insertBefore(e.firstChild, e);
|
|
1255
|
+
t.removeChild(e);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
function _t(e) {
|
|
1259
|
+
const t = [];
|
|
1260
|
+
for (let n = 0; n < e.style.length; n += 1) t.push(e.style.item(n));
|
|
1261
|
+
return t;
|
|
1262
|
+
}
|
|
1263
|
+
function pe(e) {
|
|
1264
|
+
if (!e || e.nodeType !== Node.ELEMENT_NODE || e.tagName !== "SPAN") return !1;
|
|
1265
|
+
const t = _t(e);
|
|
1266
|
+
return t.length ? t.every((n) => n === "color" || n === "background-color") : !1;
|
|
1267
|
+
}
|
|
1268
|
+
function le(e) {
|
|
1269
|
+
if (!e) return;
|
|
1270
|
+
let t = 0, n = !0;
|
|
1271
|
+
for (; n && t < 80; )
|
|
1272
|
+
n = !1, t += 1, [...e.querySelectorAll("span")].forEach((r) => {
|
|
1273
|
+
var a;
|
|
1274
|
+
if (!r.isConnected) return;
|
|
1275
|
+
if (!((a = r.getAttribute("style")) != null && a.trim()) && !r.className) {
|
|
1276
|
+
me(r), n = !0;
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
if (!pe(r)) return;
|
|
1280
|
+
const l = r.parentElement;
|
|
1281
|
+
if (l && pe(l) && l.childNodes.length === 1 && l.firstChild === r) {
|
|
1282
|
+
for (r.style.color && (l.style.color = r.style.color), r.style.backgroundColor && (l.style.backgroundColor = r.style.backgroundColor); r.firstChild; ) l.insertBefore(r.firstChild, r);
|
|
1283
|
+
r.remove(), n = !0;
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
l && pe(l) && (r.style.color && (l.style.color = r.style.color), r.style.backgroundColor && (l.style.backgroundColor = r.style.backgroundColor), me(r), n = !0);
|
|
1287
|
+
});
|
|
1288
|
+
e.querySelectorAll("span").forEach((r) => {
|
|
1289
|
+
var l;
|
|
1290
|
+
!((l = r.getAttribute("style")) != null && l.trim()) && !r.className && me(r);
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
function It(e) {
|
|
1294
|
+
return ue(e, !1);
|
|
1295
|
+
}
|
|
1296
|
+
function Rt(e) {
|
|
1297
|
+
return ue(e, !0);
|
|
1298
|
+
}
|
|
1299
|
+
const Dt = [
|
|
1300
|
+
{ mime: "image/jpeg", bytes: [255, 216, 255] },
|
|
1301
|
+
{ mime: "image/png", bytes: [137, 80, 78, 71] },
|
|
1302
|
+
{
|
|
1303
|
+
mime: "image/gif",
|
|
1304
|
+
bytes: [71, 73, 70, 56]
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
mime: "image/webp",
|
|
1308
|
+
check: (e) => e.length >= 12 && e[0] === 82 && e[1] === 73 && e[2] === 70 && e[3] === 70 && e[8] === 87 && e[9] === 69 && e[10] === 66 && e[11] === 80
|
|
1309
|
+
}
|
|
1310
|
+
], Ut = {
|
|
1311
|
+
maxSizeBytes: 2 * 1024 * 1024,
|
|
1312
|
+
allowedMimeTypes: ["image/jpeg", "image/png", "image/gif", "image/webp"],
|
|
1313
|
+
allowedExtensions: [".jpg", ".jpeg", ".png", ".gif", ".webp"]
|
|
1314
|
+
};
|
|
1315
|
+
function Ht(e) {
|
|
1316
|
+
const t = e.lastIndexOf(".");
|
|
1317
|
+
return t === -1 ? "" : e.slice(t).toLowerCase();
|
|
1318
|
+
}
|
|
1319
|
+
function Ot(e) {
|
|
1320
|
+
return e.replace(/[/\\?%*:|"<>]/g, "_").replace(/\s+/g, "-").replace(/\.+/g, ".").slice(0, 100) || "image";
|
|
1321
|
+
}
|
|
1322
|
+
async function Bt(e, t = 16) {
|
|
1323
|
+
const r = await e.slice(0, t).arrayBuffer();
|
|
1324
|
+
return new Uint8Array(r);
|
|
1325
|
+
}
|
|
1326
|
+
function Ft(e) {
|
|
1327
|
+
for (const t of Dt)
|
|
1328
|
+
if (t.check) {
|
|
1329
|
+
if (t.check(e)) return t.mime;
|
|
1330
|
+
} else if (t.bytes.every((n, r) => e[r] === n))
|
|
1331
|
+
return t.mime;
|
|
1332
|
+
return null;
|
|
1333
|
+
}
|
|
1334
|
+
function Be(e = {}) {
|
|
1335
|
+
return e.messages || Oe(e.language || "en");
|
|
1336
|
+
}
|
|
1337
|
+
async function Pt(e, t = {}) {
|
|
1338
|
+
const n = { ...Ut, ...t }, r = Be(t), l = [];
|
|
1339
|
+
if (!e || !(e instanceof Blob))
|
|
1340
|
+
return { ok: !1, errors: [r.fileInvalid] };
|
|
1341
|
+
if (e.size <= 0 && l.push(r.fileEmpty), e.size > n.maxSizeBytes) {
|
|
1342
|
+
const f = (n.maxSizeBytes / 1048576).toFixed(1);
|
|
1343
|
+
l.push(r.fileTooLarge(f));
|
|
1344
|
+
}
|
|
1345
|
+
const a = Ht(e.name || "");
|
|
1346
|
+
n.allowedExtensions.includes(a) || l.push(r.fileBadExtension);
|
|
1347
|
+
const s = (e.type || "").toLowerCase();
|
|
1348
|
+
s && !n.allowedMimeTypes.includes(s) && l.push(r.fileBadMime);
|
|
1349
|
+
let c = null;
|
|
1350
|
+
try {
|
|
1351
|
+
const f = await Bt(e);
|
|
1352
|
+
c = Ft(f), c ? s && s !== c && !(s === "image/jpg" && c === "image/jpeg") && l.push(r.fileMimeMismatch) : l.push(r.fileBadContent);
|
|
1353
|
+
} catch {
|
|
1354
|
+
l.push(r.fileReadError);
|
|
1355
|
+
}
|
|
1356
|
+
return l.length ? { ok: !1, errors: l } : {
|
|
1357
|
+
ok: !0,
|
|
1358
|
+
mime: c || s,
|
|
1359
|
+
safeName: Ot(e.name || `image${a}`),
|
|
1360
|
+
errors: []
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
function qt(e, t) {
|
|
1364
|
+
return new Promise((n, r) => {
|
|
1365
|
+
const l = new FileReader();
|
|
1366
|
+
l.onload = () => {
|
|
1367
|
+
const a = l.result;
|
|
1368
|
+
if (typeof a != "string" || !a.startsWith("data:image/")) {
|
|
1369
|
+
r(new Error("Failed to encode image."));
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
if (t && a.startsWith("data:")) {
|
|
1373
|
+
const s = a.indexOf(",");
|
|
1374
|
+
if (s !== -1) {
|
|
1375
|
+
n(`data:${t};base64,${a.slice(s + 1)}`);
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
n(a);
|
|
1380
|
+
}, l.onerror = () => r(l.error || new Error("Failed to read file.")), l.readAsDataURL(e);
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
async function jt(e, t = {}) {
|
|
1384
|
+
const n = Be(t), r = await Pt(e, t);
|
|
1385
|
+
if (!r.ok)
|
|
1386
|
+
throw new Error(r.errors.join(" "));
|
|
1387
|
+
if (typeof t.onUpload == "function") {
|
|
1388
|
+
const l = await t.onUpload(e, {
|
|
1389
|
+
mime: r.mime,
|
|
1390
|
+
safeName: r.safeName
|
|
1391
|
+
});
|
|
1392
|
+
if (!l || typeof l != "string")
|
|
1393
|
+
throw new Error(n.imageUploadFailed);
|
|
1394
|
+
return l;
|
|
1395
|
+
}
|
|
1396
|
+
try {
|
|
1397
|
+
return await qt(e, r.mime);
|
|
1398
|
+
} catch {
|
|
1399
|
+
throw new Error(n.fileReadError);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
function $t(e = 50) {
|
|
1403
|
+
let t = [], n = -1;
|
|
1404
|
+
return {
|
|
1405
|
+
push(r) {
|
|
1406
|
+
n >= 0 && t[n] === r || (t = t.slice(0, n + 1), t.push(r), t.length > e ? t.shift() : n += 1, n >= e && (n = e - 1), n = t.length - 1);
|
|
1407
|
+
},
|
|
1408
|
+
undo() {
|
|
1409
|
+
return n <= 0 ? null : (n -= 1, t[n]);
|
|
1410
|
+
},
|
|
1411
|
+
redo() {
|
|
1412
|
+
return n >= t.length - 1 ? null : (n += 1, t[n]);
|
|
1413
|
+
},
|
|
1414
|
+
canUndo() {
|
|
1415
|
+
return n > 0;
|
|
1416
|
+
},
|
|
1417
|
+
canRedo() {
|
|
1418
|
+
return n < t.length - 1;
|
|
1419
|
+
},
|
|
1420
|
+
current() {
|
|
1421
|
+
return n >= 0 ? t[n] : null;
|
|
1422
|
+
},
|
|
1423
|
+
reset(r = "") {
|
|
1424
|
+
t = [r], n = 0;
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
function J(e) {
|
|
1429
|
+
e && e.focus({ preventScroll: !0 });
|
|
1430
|
+
}
|
|
1431
|
+
function re(e) {
|
|
1432
|
+
const t = window.getSelection();
|
|
1433
|
+
if (!t || t.rangeCount === 0) return null;
|
|
1434
|
+
const n = t.getRangeAt(0);
|
|
1435
|
+
return e.contains(n.commonAncestorContainer) ? n.cloneRange() : null;
|
|
1436
|
+
}
|
|
1437
|
+
function de(e) {
|
|
1438
|
+
if (!e) return !1;
|
|
1439
|
+
const t = window.getSelection();
|
|
1440
|
+
if (!t) return !1;
|
|
1441
|
+
try {
|
|
1442
|
+
return t.removeAllRanges(), t.addRange(e), !0;
|
|
1443
|
+
} catch {
|
|
1444
|
+
return !1;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
function O(e, t = null) {
|
|
1448
|
+
try {
|
|
1449
|
+
return document.execCommand(e, !1, t);
|
|
1450
|
+
} catch {
|
|
1451
|
+
return !1;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
function X(e) {
|
|
1455
|
+
try {
|
|
1456
|
+
return document.queryCommandState(e);
|
|
1457
|
+
} catch {
|
|
1458
|
+
return !1;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
function zt(e) {
|
|
1462
|
+
try {
|
|
1463
|
+
return document.queryCommandValue(e);
|
|
1464
|
+
} catch {
|
|
1465
|
+
return "";
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
function Wt() {
|
|
1469
|
+
const e = (zt("formatBlock") || "").toLowerCase();
|
|
1470
|
+
return e ? e.replace(/[<>]/g, "") : "p";
|
|
1471
|
+
}
|
|
1472
|
+
function Fe() {
|
|
1473
|
+
try {
|
|
1474
|
+
document.execCommand("styleWithCSS", !1, !0);
|
|
1475
|
+
} catch {
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
function ie(e) {
|
|
1479
|
+
const t = window.getSelection();
|
|
1480
|
+
if (!t || t.rangeCount === 0) return null;
|
|
1481
|
+
const n = t.getRangeAt(0);
|
|
1482
|
+
return e.contains(n.commonAncestorContainer) ? n : null;
|
|
1483
|
+
}
|
|
1484
|
+
function _e(e, t) {
|
|
1485
|
+
J(e);
|
|
1486
|
+
let n = ie(e);
|
|
1487
|
+
if (!n) return !1;
|
|
1488
|
+
if (n.collapsed) {
|
|
1489
|
+
const a = Kt(n);
|
|
1490
|
+
if (a)
|
|
1491
|
+
de(a), n = a;
|
|
1492
|
+
else {
|
|
1493
|
+
const s = document.createElement("span");
|
|
1494
|
+
t.color && (s.style.color = t.color), t.backgroundColor && (s.style.backgroundColor = t.backgroundColor), s.appendChild(document.createTextNode("")), n.insertNode(s);
|
|
1495
|
+
const c = document.createRange();
|
|
1496
|
+
return c.setStart(s.firstChild, 1), c.collapse(!0), de(c), !0;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
if (Gt(n, t))
|
|
1500
|
+
return le(e), !0;
|
|
1501
|
+
const l = Jt(e, t);
|
|
1502
|
+
return le(e), l;
|
|
1503
|
+
}
|
|
1504
|
+
function Kt(e) {
|
|
1505
|
+
const t = e.startContainer;
|
|
1506
|
+
if (!t || t.nodeType !== Node.TEXT_NODE) return null;
|
|
1507
|
+
const n = t.textContent || "";
|
|
1508
|
+
if (!n.trim()) return null;
|
|
1509
|
+
let r = e.startOffset, l = e.endOffset;
|
|
1510
|
+
for (; r > 0 && !/\s/.test(n[r - 1]); ) r -= 1;
|
|
1511
|
+
for (; l < n.length && !/\s/.test(n[l]); ) l += 1;
|
|
1512
|
+
if (r === l) return null;
|
|
1513
|
+
const a = e.cloneRange();
|
|
1514
|
+
return a.setStart(t, r), a.setEnd(t, l), a;
|
|
1515
|
+
}
|
|
1516
|
+
function Vt(e) {
|
|
1517
|
+
const t = [];
|
|
1518
|
+
for (let n = 0; n < e.style.length; n += 1) t.push(e.style.item(n));
|
|
1519
|
+
return t;
|
|
1520
|
+
}
|
|
1521
|
+
function Xt(e) {
|
|
1522
|
+
if (!e || e.nodeType !== Node.ELEMENT_NODE || e.tagName !== "SPAN") return !1;
|
|
1523
|
+
const t = Vt(e);
|
|
1524
|
+
return t.length ? t.every((n) => n === "color" || n === "background-color") : !1;
|
|
1525
|
+
}
|
|
1526
|
+
function Gt(e, t) {
|
|
1527
|
+
var s;
|
|
1528
|
+
let n = e.commonAncestorContainer;
|
|
1529
|
+
n.nodeType === Node.TEXT_NODE && (n = n.parentElement);
|
|
1530
|
+
let r = null, l = n;
|
|
1531
|
+
for (; l; ) {
|
|
1532
|
+
if (Xt(l)) {
|
|
1533
|
+
const c = document.createRange();
|
|
1534
|
+
if (c.selectNodeContents(l), e.compareBoundaryPoints(Range.START_TO_START, c) >= 0 && e.compareBoundaryPoints(Range.END_TO_END, c) <= 0) {
|
|
1535
|
+
r = l;
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
if ((s = l.classList) != null && s.contains("te-editor")) break;
|
|
1540
|
+
l = l.parentElement;
|
|
1541
|
+
}
|
|
1542
|
+
if (!r) return !1;
|
|
1543
|
+
t.color && (r.style.color = t.color), t.backgroundColor && (t.backgroundColor === "transparent" ? r.style.backgroundColor = "" : r.style.backgroundColor = t.backgroundColor);
|
|
1544
|
+
const a = window.getSelection();
|
|
1545
|
+
if (a) {
|
|
1546
|
+
const c = document.createRange();
|
|
1547
|
+
c.selectNodeContents(r), a.removeAllRanges(), a.addRange(c);
|
|
1548
|
+
}
|
|
1549
|
+
return !0;
|
|
1550
|
+
}
|
|
1551
|
+
function Jt(e, t) {
|
|
1552
|
+
const n = ie(e);
|
|
1553
|
+
if (!n || n.collapsed) return !1;
|
|
1554
|
+
const r = document.createElement("span");
|
|
1555
|
+
t.color && (r.style.color = t.color), t.backgroundColor && (r.style.backgroundColor = t.backgroundColor);
|
|
1556
|
+
try {
|
|
1557
|
+
n.surroundContents(r);
|
|
1558
|
+
} catch {
|
|
1559
|
+
const a = n.extractContents(), s = document.createElement("div");
|
|
1560
|
+
for (s.appendChild(a), le(s); s.firstChild; ) r.appendChild(s.firstChild);
|
|
1561
|
+
n.insertNode(r);
|
|
1562
|
+
}
|
|
1563
|
+
const l = window.getSelection();
|
|
1564
|
+
if (l) {
|
|
1565
|
+
const a = document.createRange();
|
|
1566
|
+
a.selectNodeContents(r), l.removeAllRanges(), l.addRange(a);
|
|
1567
|
+
}
|
|
1568
|
+
return !0;
|
|
1569
|
+
}
|
|
1570
|
+
function Qt(e) {
|
|
1571
|
+
J(e);
|
|
1572
|
+
const t = ie(e);
|
|
1573
|
+
t && (Fe(), O("hiliteColor", "transparent"), O("backColor", "transparent"), e.querySelectorAll("span[style]").forEach((n) => {
|
|
1574
|
+
var r;
|
|
1575
|
+
t.intersectsNode(n) && (n.style.backgroundColor = "", (r = n.getAttribute("style")) != null && r.trim() || n.removeAttribute("style"));
|
|
1576
|
+
}), le(e));
|
|
1577
|
+
}
|
|
1578
|
+
function Ie(e, t, n, r = {}) {
|
|
1579
|
+
switch (J(e), Fe(), t) {
|
|
1580
|
+
case "bold":
|
|
1581
|
+
O("bold");
|
|
1582
|
+
break;
|
|
1583
|
+
case "italic":
|
|
1584
|
+
O("italic");
|
|
1585
|
+
break;
|
|
1586
|
+
case "strikeThrough":
|
|
1587
|
+
O("strikeThrough");
|
|
1588
|
+
break;
|
|
1589
|
+
case "formatBlock": {
|
|
1590
|
+
const l = n || "p";
|
|
1591
|
+
O("formatBlock", l === "p" ? "p" : l);
|
|
1592
|
+
break;
|
|
1593
|
+
}
|
|
1594
|
+
case "insertUnorderedList":
|
|
1595
|
+
O("insertUnorderedList");
|
|
1596
|
+
break;
|
|
1597
|
+
case "insertOrderedList":
|
|
1598
|
+
O("insertOrderedList");
|
|
1599
|
+
break;
|
|
1600
|
+
case "justifyRight":
|
|
1601
|
+
be(e, "right", r.selectedImage);
|
|
1602
|
+
break;
|
|
1603
|
+
case "justifyCenter":
|
|
1604
|
+
be(e, "center", r.selectedImage);
|
|
1605
|
+
break;
|
|
1606
|
+
case "justifyLeft":
|
|
1607
|
+
be(e, "left", r.selectedImage);
|
|
1608
|
+
break;
|
|
1609
|
+
case "indent":
|
|
1610
|
+
Re(e, 1);
|
|
1611
|
+
break;
|
|
1612
|
+
case "outdent":
|
|
1613
|
+
Re(e, -1);
|
|
1614
|
+
break;
|
|
1615
|
+
case "insertHorizontalRule":
|
|
1616
|
+
O("insertHorizontalRule");
|
|
1617
|
+
break;
|
|
1618
|
+
case "foreColor":
|
|
1619
|
+
_e(e, { color: n });
|
|
1620
|
+
break;
|
|
1621
|
+
case "hiliteColor":
|
|
1622
|
+
!n || n === "transparent" ? Qt(e) : _e(e, { backgroundColor: n });
|
|
1623
|
+
break;
|
|
1624
|
+
case "removeFormat":
|
|
1625
|
+
O("removeFormat");
|
|
1626
|
+
break;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
function Pe(e, t) {
|
|
1630
|
+
var r;
|
|
1631
|
+
let n = t;
|
|
1632
|
+
for (n && n.nodeType === Node.TEXT_NODE && (n = n.parentElement); n && n !== e; ) {
|
|
1633
|
+
if ((r = n.matches) != null && r.call(
|
|
1634
|
+
n,
|
|
1635
|
+
"p,div,h1,h2,h3,h4,h5,h6,li,blockquote,pre,figure,.te-figure"
|
|
1636
|
+
))
|
|
1637
|
+
return n;
|
|
1638
|
+
n = n.parentElement;
|
|
1639
|
+
}
|
|
1640
|
+
return null;
|
|
1641
|
+
}
|
|
1642
|
+
const Yt = 24, Zt = 240;
|
|
1643
|
+
function er(e) {
|
|
1644
|
+
var r, l, a, s;
|
|
1645
|
+
const t = (r = e.style) == null ? void 0 : r.marginInlineStart;
|
|
1646
|
+
if (t) {
|
|
1647
|
+
const c = parseFloat(t);
|
|
1648
|
+
if (!Number.isNaN(c)) return c;
|
|
1649
|
+
}
|
|
1650
|
+
const n = (s = (a = (l = e.ownerDocument) == null ? void 0 : l.defaultView) == null ? void 0 : a.getComputedStyle(e)) == null ? void 0 : s.marginInlineStart;
|
|
1651
|
+
if (n) {
|
|
1652
|
+
const c = parseFloat(n);
|
|
1653
|
+
if (!Number.isNaN(c) && c > 0) return c;
|
|
1654
|
+
}
|
|
1655
|
+
return 0;
|
|
1656
|
+
}
|
|
1657
|
+
function tr(e, t) {
|
|
1658
|
+
const n = [], r = /* @__PURE__ */ new Set(), l = (a) => {
|
|
1659
|
+
var c;
|
|
1660
|
+
const s = Pe(e, a);
|
|
1661
|
+
!s || s === e || r.has(s) || (c = s.matches) != null && c.call(s, "figure,.te-figure") || (r.add(s), n.push(s));
|
|
1662
|
+
};
|
|
1663
|
+
if (l(t.startContainer), l(t.endContainer), !t.collapsed)
|
|
1664
|
+
try {
|
|
1665
|
+
const a = e.ownerDocument.createTreeWalker(
|
|
1666
|
+
t.commonAncestorContainer.nodeType === Node.ELEMENT_NODE ? t.commonAncestorContainer : t.commonAncestorContainer.parentElement || e,
|
|
1667
|
+
NodeFilter.SHOW_ELEMENT,
|
|
1668
|
+
{
|
|
1669
|
+
acceptNode(c) {
|
|
1670
|
+
var f;
|
|
1671
|
+
return t.intersectsNode(c) ? (f = c.matches) != null && f.call(
|
|
1672
|
+
c,
|
|
1673
|
+
"p,div,h1,h2,h3,h4,h5,h6,li,blockquote,pre"
|
|
1674
|
+
) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP : NodeFilter.FILTER_REJECT;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
);
|
|
1678
|
+
let s = a.currentNode;
|
|
1679
|
+
for ((s == null ? void 0 : s.nodeType) === Node.ELEMENT_NODE && l(s); s = a.nextNode(); ) l(s);
|
|
1680
|
+
} catch {
|
|
1681
|
+
}
|
|
1682
|
+
return n;
|
|
1683
|
+
}
|
|
1684
|
+
function Re(e, t) {
|
|
1685
|
+
J(e);
|
|
1686
|
+
const n = ie(e);
|
|
1687
|
+
if (!n) return;
|
|
1688
|
+
const r = tr(e, n);
|
|
1689
|
+
r.length && r.forEach((l) => {
|
|
1690
|
+
var c;
|
|
1691
|
+
if (l.tagName === "LI") {
|
|
1692
|
+
rr(l, t);
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
const a = er(l), s = Math.max(
|
|
1696
|
+
0,
|
|
1697
|
+
Math.min(Zt, a + t * Yt)
|
|
1698
|
+
);
|
|
1699
|
+
s <= 0 ? (l.style.marginInlineStart = "", (c = l.getAttribute("style")) != null && c.trim() || l.removeAttribute("style")) : l.style.marginInlineStart = `${s}px`;
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
function rr(e, t) {
|
|
1703
|
+
const n = e.parentElement;
|
|
1704
|
+
if (!n || n.tagName !== "UL" && n.tagName !== "OL") return;
|
|
1705
|
+
if (t > 0) {
|
|
1706
|
+
const a = e.previousElementSibling;
|
|
1707
|
+
if (!a || a.tagName !== "LI") return;
|
|
1708
|
+
let s = a.querySelector(":scope > ul, :scope > ol");
|
|
1709
|
+
s || (s = document.createElement(n.tagName.toLowerCase()), a.appendChild(s)), s.appendChild(e);
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
const r = n.parentElement;
|
|
1713
|
+
!r || r.tagName !== "LI" || !r.parentElement || (r.after(e), n.children.length || n.remove());
|
|
1714
|
+
}
|
|
1715
|
+
function be(e, t, n) {
|
|
1716
|
+
var c, f;
|
|
1717
|
+
const r = n && e.contains(n) ? n : null;
|
|
1718
|
+
if (r) {
|
|
1719
|
+
De(r, t);
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
const l = ie(e), a = l == null ? void 0 : l.commonAncestorContainer, s = (a == null ? void 0 : a.nodeType) === Node.ELEMENT_NODE && a.tagName === "IMG" ? a : (f = (c = a == null ? void 0 : a.parentElement) == null ? void 0 : c.closest) == null ? void 0 : f.call(c, "img");
|
|
1723
|
+
if (s && e.contains(s)) {
|
|
1724
|
+
De(s, t);
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
O(t === "right" ? "justifyRight" : t === "center" ? "justifyCenter" : "justifyLeft");
|
|
1728
|
+
}
|
|
1729
|
+
function qe(e) {
|
|
1730
|
+
var n, r;
|
|
1731
|
+
if ((r = (n = e.parentElement) == null ? void 0 : n.classList) != null && r.contains("te-figure"))
|
|
1732
|
+
return e.parentElement;
|
|
1733
|
+
const t = document.createElement("div");
|
|
1734
|
+
return t.className = "te-figure", t.setAttribute("contenteditable", "false"), e.replaceWith(t), t.appendChild(e), t;
|
|
1735
|
+
}
|
|
1736
|
+
function De(e, t) {
|
|
1737
|
+
const n = qe(e);
|
|
1738
|
+
n.setAttribute("data-align", t), n.style.textAlign = t, n.style.width = "fit-content", n.style.maxWidth = "100%", e.style.display = "block", e.style.float = "none", e.style.marginLeft = "0", e.style.marginRight = "0", t === "center" ? (n.style.marginLeft = "auto", n.style.marginRight = "auto") : t === "left" ? (n.style.marginLeft = "0", n.style.marginRight = "auto") : (n.style.marginLeft = "auto", n.style.marginRight = "0");
|
|
1739
|
+
}
|
|
1740
|
+
function ne(e, t, n) {
|
|
1741
|
+
if (!e || !t) return;
|
|
1742
|
+
ce(t);
|
|
1743
|
+
const r = qe(e);
|
|
1744
|
+
r.classList.add("is-selected"), e.classList.add("is-selected");
|
|
1745
|
+
let l = r.querySelector(".te-figure__alt-btn");
|
|
1746
|
+
l || (l = document.createElement("button"), l.type = "button", l.className = "te-figure__alt-btn", l.setAttribute("contenteditable", "false"), r.appendChild(l));
|
|
1747
|
+
const a = n || {}, s = e.getAttribute("alt") || "";
|
|
1748
|
+
l.textContent = s ? `Alt: ${s.length > 28 ? `${s.slice(0, 28)}…` : s}` : a.editAlt || "Edit Alt", l.title = a.editAltTitle || "Edit image alt text";
|
|
1749
|
+
const c = document.createRange();
|
|
1750
|
+
c.selectNode(r);
|
|
1751
|
+
const f = window.getSelection();
|
|
1752
|
+
f == null || f.removeAllRanges(), f == null || f.addRange(c), J(t);
|
|
1753
|
+
}
|
|
1754
|
+
function ce(e) {
|
|
1755
|
+
e && (e.querySelectorAll(".te-figure.is-selected, img.is-selected").forEach((t) => {
|
|
1756
|
+
t.classList.remove("is-selected");
|
|
1757
|
+
}), e.querySelectorAll(".te-figure__alt-btn").forEach((t) => t.remove()));
|
|
1758
|
+
}
|
|
1759
|
+
function nr(e, t, n) {
|
|
1760
|
+
var a;
|
|
1761
|
+
if (!e) return;
|
|
1762
|
+
e.setAttribute("alt", t || "");
|
|
1763
|
+
const r = (a = e.closest) == null ? void 0 : a.call(e, ".te-figure"), l = r == null ? void 0 : r.querySelector(".te-figure__alt-btn");
|
|
1764
|
+
if (l) {
|
|
1765
|
+
const s = n || {};
|
|
1766
|
+
l.textContent = t ? `Alt: ${t.length > 28 ? `${t.slice(0, 28)}…` : t}` : s.editAlt || "Edit Alt";
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
function lr(e, t) {
|
|
1770
|
+
J(e);
|
|
1771
|
+
const n = window.getSelection();
|
|
1772
|
+
if (!n || n.rangeCount === 0) {
|
|
1773
|
+
e.setAttribute("dir", t);
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
let r = n.anchorNode;
|
|
1777
|
+
r && r.nodeType === Node.TEXT_NODE && (r = r.parentElement);
|
|
1778
|
+
const l = Pe(e, r);
|
|
1779
|
+
l && l !== e ? (l.setAttribute("dir", t), l.style.direction = t) : e.setAttribute("dir", t);
|
|
1780
|
+
}
|
|
1781
|
+
function ir(e, t, n, r) {
|
|
1782
|
+
if (J(e), !It(t))
|
|
1783
|
+
throw new Error(r && r.linkUnsafe || "The link URL is invalid or unsafe.");
|
|
1784
|
+
const l = window.getSelection();
|
|
1785
|
+
if (l && !l.isCollapsed && e.contains(l.anchorNode)) {
|
|
1786
|
+
O("createLink", t);
|
|
1787
|
+
const s = e.querySelectorAll("a[href]"), c = s[s.length - 1];
|
|
1788
|
+
c && (c.setAttribute("rel", "noopener noreferrer"), /^https?:/i.test(t) && c.setAttribute("target", "_blank"));
|
|
1789
|
+
} else {
|
|
1790
|
+
const s = n || t, c = document.createElement("a");
|
|
1791
|
+
c.href = t, c.textContent = s, c.rel = "noopener noreferrer", /^https?:/i.test(t) && (c.target = "_blank"), ke(e, c);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
function Ue(e, t, n = "", r) {
|
|
1795
|
+
if (J(e), !Rt(t))
|
|
1796
|
+
throw new Error(r && r.imageUnsafe || "The image URL is invalid or unsafe.");
|
|
1797
|
+
const l = document.createElement("div");
|
|
1798
|
+
l.className = "te-figure", l.setAttribute("contenteditable", "false"), l.setAttribute("data-align", "center"), l.style.textAlign = "center", l.style.width = "fit-content", l.style.maxWidth = "100%", l.style.marginLeft = "auto", l.style.marginRight = "auto";
|
|
1799
|
+
const a = document.createElement("img");
|
|
1800
|
+
a.src = t, a.alt = n || "", a.setAttribute("loading", "lazy"), a.draggable = !1, a.style.display = "block", a.style.maxWidth = "100%", l.appendChild(a), ke(e, l);
|
|
1801
|
+
const s = document.createElement("p");
|
|
1802
|
+
return s.innerHTML = "<br>", ke(e, s), a;
|
|
1803
|
+
}
|
|
1804
|
+
function ke(e, t) {
|
|
1805
|
+
const n = window.getSelection();
|
|
1806
|
+
if (!n || n.rangeCount === 0) {
|
|
1807
|
+
e.appendChild(t);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
const r = n.getRangeAt(0);
|
|
1811
|
+
if (!e.contains(r.commonAncestorContainer)) {
|
|
1812
|
+
e.appendChild(t);
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
r.deleteContents(), r.insertNode(t), r.setStartAfter(t), r.collapse(!0), n.removeAllRanges(), n.addRange(r);
|
|
1816
|
+
}
|
|
1817
|
+
function ar(e) {
|
|
1818
|
+
var r, l, a;
|
|
1819
|
+
const t = (r = e == null ? void 0 : e.querySelector) == null ? void 0 : r.call(e, ".te-figure.is-selected, img.is-selected");
|
|
1820
|
+
let n = null;
|
|
1821
|
+
if (t) {
|
|
1822
|
+
const s = (l = t.classList) != null && l.contains("te-figure") ? t : (a = t.closest) == null ? void 0 : a.call(t, ".te-figure");
|
|
1823
|
+
n = (s == null ? void 0 : s.getAttribute("data-align")) || null;
|
|
1824
|
+
}
|
|
1825
|
+
return {
|
|
1826
|
+
bold: X("bold"),
|
|
1827
|
+
italic: X("italic"),
|
|
1828
|
+
strikeThrough: X("strikeThrough"),
|
|
1829
|
+
unorderedList: X("insertUnorderedList"),
|
|
1830
|
+
orderedList: X("insertOrderedList"),
|
|
1831
|
+
justifyRight: n ? n === "right" : X("justifyRight"),
|
|
1832
|
+
justifyCenter: n ? n === "center" : X("justifyCenter"),
|
|
1833
|
+
justifyLeft: n ? n === "left" : X("justifyLeft"),
|
|
1834
|
+
format: Wt(),
|
|
1835
|
+
hasSelectedImage: !!t
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
function Z(e) {
|
|
1839
|
+
const t = (e || "").trim();
|
|
1840
|
+
return !t || t === "<br>" || t === "<div><br></div>" ? "<p><br></p>" : t;
|
|
1841
|
+
}
|
|
1842
|
+
function ye(e) {
|
|
1843
|
+
if (typeof document < "u") {
|
|
1844
|
+
const t = document.createElement("div");
|
|
1845
|
+
return t.innerHTML = e, t.querySelectorAll(".te-figure__alt-btn").forEach((n) => n.remove()), t.querySelectorAll(".is-selected").forEach((n) => n.classList.remove("is-selected")), t.querySelectorAll('[class=""]').forEach((n) => n.removeAttribute("class")), t.innerHTML;
|
|
1846
|
+
}
|
|
1847
|
+
return e.replace(/<button[^>]*class="[^"]*te-figure__alt-btn[^"]*"[^>]*>.*?<\/button>/gi, "").replace(/\s*is-selected/g, "").replace(/\sclass=""/g, "").replace(/\sclass=''/g, "");
|
|
1848
|
+
}
|
|
1849
|
+
const ur = dt(function({
|
|
1850
|
+
value: t,
|
|
1851
|
+
defaultValue: n = "<p><br></p>",
|
|
1852
|
+
onChange: r,
|
|
1853
|
+
placeholder: l,
|
|
1854
|
+
language: a = "en",
|
|
1855
|
+
dir: s,
|
|
1856
|
+
className: c = "",
|
|
1857
|
+
style: f,
|
|
1858
|
+
minHeight: v = 220,
|
|
1859
|
+
disabled: m = !1,
|
|
1860
|
+
onUpload: S,
|
|
1861
|
+
uploadOptions: I,
|
|
1862
|
+
toolbar: T = !0
|
|
1863
|
+
}, x) {
|
|
1864
|
+
const w = Le(a), _ = Oe(w), k = s || yt(w), h = l ?? _.placeholder, p = F(null), u = F(null), D = F($t()), P = F(null), q = F(""), fe = F(!1), R = F(null), j = F(_);
|
|
1865
|
+
j.current = _;
|
|
1866
|
+
const [je, $e] = E(() => ({
|
|
1867
|
+
bold: !1,
|
|
1868
|
+
italic: !1,
|
|
1869
|
+
strikeThrough: !1,
|
|
1870
|
+
unorderedList: !1,
|
|
1871
|
+
orderedList: !1,
|
|
1872
|
+
justifyRight: !1,
|
|
1873
|
+
justifyCenter: !1,
|
|
1874
|
+
justifyLeft: !1,
|
|
1875
|
+
format: "p",
|
|
1876
|
+
hasSelectedImage: !1
|
|
1877
|
+
})), [ze, We] = E(!1), [Ke, Ve] = E(!1), [Xe, Ee] = E(!1), [Ge, Ae] = E(!1), [Je, we] = E(!1), [Qe, Ye] = E(""), [Ze, Q] = E(!0), [B, Ne] = E(!1), [te, Te] = E(""), $ = A(() => {
|
|
1878
|
+
We(D.current.canUndo()), Ve(D.current.canRedo());
|
|
1879
|
+
}, []), V = A(
|
|
1880
|
+
(o, { recordHistory: g = !0 } = {}) => {
|
|
1881
|
+
const y = W(ye(Z(o)));
|
|
1882
|
+
q.current = y, Q(!y.replace(/<[^>]+>/g, "").replace(/\u200b/g, "").trim()), g && (D.current.push(y), $()), r == null || r(y);
|
|
1883
|
+
},
|
|
1884
|
+
[r, $]
|
|
1885
|
+
), z = A(() => {
|
|
1886
|
+
var o;
|
|
1887
|
+
return ((o = u.current) == null ? void 0 : o.innerHTML) || "";
|
|
1888
|
+
}, []), xe = A(
|
|
1889
|
+
(o, { recordHistory: g = !1 } = {}) => {
|
|
1890
|
+
if (!u.current) return;
|
|
1891
|
+
const y = W(Z(o));
|
|
1892
|
+
u.current.innerHTML = y, q.current = y, Q(!y.replace(/<[^>]+>/g, "").replace(/\u200b/g, "").trim()), R.current = null, g && (D.current.push(y), $());
|
|
1893
|
+
},
|
|
1894
|
+
[$]
|
|
1895
|
+
);
|
|
1896
|
+
G(() => {
|
|
1897
|
+
const o = W(Z(t ?? n));
|
|
1898
|
+
u.current && (u.current.innerHTML = o), q.current = o, D.current.reset(o), Q(!o.replace(/<[^>]+>/g, "").replace(/\u200b/g, "").trim()), $();
|
|
1899
|
+
}, []), G(() => {
|
|
1900
|
+
if (t === void 0 || !u.current) return;
|
|
1901
|
+
const o = W(Z(t));
|
|
1902
|
+
if (o !== q.current) {
|
|
1903
|
+
const g = re(u.current);
|
|
1904
|
+
u.current.innerHTML = o, q.current = o, Q(!o.replace(/<[^>]+>/g, "").replace(/\u200b/g, "").trim()), R.current = null, de(g);
|
|
1905
|
+
}
|
|
1906
|
+
}, [t]);
|
|
1907
|
+
const N = A(() => {
|
|
1908
|
+
u.current && $e(ar(u.current));
|
|
1909
|
+
}, []);
|
|
1910
|
+
G(() => {
|
|
1911
|
+
const o = () => {
|
|
1912
|
+
if (!u.current) return;
|
|
1913
|
+
const g = window.getSelection();
|
|
1914
|
+
!g || g.rangeCount === 0 || u.current.contains(g.anchorNode) && N();
|
|
1915
|
+
};
|
|
1916
|
+
return document.addEventListener("selectionchange", o), () => document.removeEventListener("selectionchange", o);
|
|
1917
|
+
}, [N]);
|
|
1918
|
+
const ee = A(() => {
|
|
1919
|
+
const o = re(u.current);
|
|
1920
|
+
o && (P.current = o);
|
|
1921
|
+
}, []), Y = A(
|
|
1922
|
+
(o) => {
|
|
1923
|
+
const g = re(u.current);
|
|
1924
|
+
g && (P.current = g), de(P.current), o(), V(z()), N();
|
|
1925
|
+
},
|
|
1926
|
+
[V, z, N]
|
|
1927
|
+
), ae = A(
|
|
1928
|
+
(o, g) => {
|
|
1929
|
+
m || Y(() => {
|
|
1930
|
+
o === "rtl" || o === "ltr" ? lr(u.current, o) : Ie(u.current, o, g, {
|
|
1931
|
+
selectedImage: R.current
|
|
1932
|
+
});
|
|
1933
|
+
});
|
|
1934
|
+
},
|
|
1935
|
+
[m, Y]
|
|
1936
|
+
), et = A(
|
|
1937
|
+
(o) => {
|
|
1938
|
+
m || Y(() => {
|
|
1939
|
+
Ie(u.current, "formatBlock", o);
|
|
1940
|
+
});
|
|
1941
|
+
},
|
|
1942
|
+
[m, Y]
|
|
1943
|
+
), ge = A(() => {
|
|
1944
|
+
const o = D.current.undo();
|
|
1945
|
+
o == null || !u.current || (u.current.innerHTML = o, q.current = o, Q(!o.replace(/<[^>]+>/g, "").replace(/\u200b/g, "").trim()), R.current = null, $(), r == null || r(o), N());
|
|
1946
|
+
}, [r, N, $]), he = A(() => {
|
|
1947
|
+
const o = D.current.redo();
|
|
1948
|
+
o == null || !u.current || (u.current.innerHTML = o, q.current = o, Q(!o.replace(/<[^>]+>/g, "").replace(/\u200b/g, "").trim()), R.current = null, $(), r == null || r(o), N());
|
|
1949
|
+
}, [r, N, $]), Me = A(() => {
|
|
1950
|
+
fe.current || (V(z()), N());
|
|
1951
|
+
}, [V, z, N]), tt = A(
|
|
1952
|
+
(o) => {
|
|
1953
|
+
var H, U;
|
|
1954
|
+
o.preventDefault();
|
|
1955
|
+
const g = ((H = o.clipboardData) == null ? void 0 : H.getData("text/plain")) || "", y = (U = o.clipboardData) == null ? void 0 : U.getData("text/html");
|
|
1956
|
+
if (y) {
|
|
1957
|
+
const se = W(y);
|
|
1958
|
+
document.execCommand("insertHTML", !1, se);
|
|
1959
|
+
} else
|
|
1960
|
+
document.execCommand("insertText", !1, g);
|
|
1961
|
+
V(z());
|
|
1962
|
+
},
|
|
1963
|
+
[V, z]
|
|
1964
|
+
), rt = A(
|
|
1965
|
+
(o) => {
|
|
1966
|
+
const g = o.metaKey || o.ctrlKey;
|
|
1967
|
+
g && o.key.toLowerCase() === "z" && !o.shiftKey ? (o.preventDefault(), ge()) : g && (o.key.toLowerCase() === "y" || o.key.toLowerCase() === "z" && o.shiftKey) ? (o.preventDefault(), he()) : g && o.key.toLowerCase() === "b" ? (o.preventDefault(), ae("bold")) : g && o.key.toLowerCase() === "i" ? (o.preventDefault(), ae("italic")) : o.key === "Escape" && R.current && (ce(u.current), R.current = null, N());
|
|
1968
|
+
},
|
|
1969
|
+
[ae, he, ge, N]
|
|
1970
|
+
), oe = A((o) => {
|
|
1971
|
+
o && (R.current = o, Ye(o.getAttribute("alt") || ""), we(!0));
|
|
1972
|
+
}, []), nt = A(
|
|
1973
|
+
(o) => {
|
|
1974
|
+
const g = o.target;
|
|
1975
|
+
if (!(g instanceof Element) || !u.current) return;
|
|
1976
|
+
if (g.closest(".te-figure__alt-btn")) {
|
|
1977
|
+
o.preventDefault(), o.stopPropagation();
|
|
1978
|
+
const U = g.closest(".te-figure"), se = U == null ? void 0 : U.querySelector("img");
|
|
1979
|
+
se && oe(se);
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
const y = g.closest("img"), H = g.closest(".te-figure");
|
|
1983
|
+
if (y && u.current.contains(y)) {
|
|
1984
|
+
o.preventDefault(), ne(y, u.current, j.current), R.current = y, P.current = re(u.current), N();
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1987
|
+
if (H && u.current.contains(H)) {
|
|
1988
|
+
const U = H.querySelector("img");
|
|
1989
|
+
if (U) {
|
|
1990
|
+
o.preventDefault(), ne(U, u.current, j.current), R.current = U, P.current = re(u.current), N();
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
R.current && (ce(u.current), R.current = null, N());
|
|
1995
|
+
},
|
|
1996
|
+
[oe, N]
|
|
1997
|
+
), lt = A(
|
|
1998
|
+
(o) => {
|
|
1999
|
+
const g = o.target;
|
|
2000
|
+
if (!(g instanceof Element) || !u.current) return;
|
|
2001
|
+
const y = g.closest("img"), H = g.closest(".te-figure"), U = y || (H == null ? void 0 : H.querySelector("img"));
|
|
2002
|
+
U && u.current.contains(U) && (o.preventDefault(), ne(U, u.current, j.current), oe(U));
|
|
2003
|
+
},
|
|
2004
|
+
[oe]
|
|
2005
|
+
), it = A(() => {
|
|
2006
|
+
ee(), Ee(!0);
|
|
2007
|
+
}, [ee]), at = A(() => {
|
|
2008
|
+
ee(), Ae(!0);
|
|
2009
|
+
}, [ee]), ot = A(() => {
|
|
2010
|
+
if (m) return;
|
|
2011
|
+
if (!B) {
|
|
2012
|
+
ce(u.current), R.current = null;
|
|
2013
|
+
const g = W(ye(z()));
|
|
2014
|
+
Te(g), Ne(!0);
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
const o = W(Z(te));
|
|
2018
|
+
u.current && (u.current.innerHTML = o), q.current = o, Q(!o.replace(/<[^>]+>/g, "").replace(/\u200b/g, "").trim()), D.current.push(o), $(), r == null || r(o), Ne(!1), N();
|
|
2019
|
+
}, [
|
|
2020
|
+
m,
|
|
2021
|
+
B,
|
|
2022
|
+
te,
|
|
2023
|
+
z,
|
|
2024
|
+
r,
|
|
2025
|
+
$,
|
|
2026
|
+
N
|
|
2027
|
+
]), st = A((o) => {
|
|
2028
|
+
Te(o.target.value);
|
|
2029
|
+
}, []), ct = A(() => {
|
|
2030
|
+
const o = W(Z(te));
|
|
2031
|
+
q.current = o, r == null || r(o);
|
|
2032
|
+
}, [te, r]);
|
|
2033
|
+
return ft(x, () => ({
|
|
2034
|
+
focus: () => {
|
|
2035
|
+
var o;
|
|
2036
|
+
return (o = u.current) == null ? void 0 : o.focus();
|
|
2037
|
+
},
|
|
2038
|
+
getHTML: () => W(ye(z())),
|
|
2039
|
+
setHTML: (o) => {
|
|
2040
|
+
xe(o, { recordHistory: !0 }), r == null || r(W(Z(o)));
|
|
2041
|
+
},
|
|
2042
|
+
clear: () => {
|
|
2043
|
+
xe("<p><br></p>", { recordHistory: !0 }), r == null || r(W("<p><br></p>"));
|
|
2044
|
+
},
|
|
2045
|
+
getEditorElement: () => u.current
|
|
2046
|
+
})), /* @__PURE__ */ d(
|
|
2047
|
+
"div",
|
|
2048
|
+
{
|
|
2049
|
+
ref: p,
|
|
2050
|
+
className: `te-root${m ? " is-disabled" : ""}${B ? " is-source" : ""} te-root--${k} ${c}`.trim(),
|
|
2051
|
+
style: f,
|
|
2052
|
+
dir: k,
|
|
2053
|
+
lang: w,
|
|
2054
|
+
onMouseDown: (o) => {
|
|
2055
|
+
var g, y;
|
|
2056
|
+
(y = (g = o.target).closest) != null && y.call(g, ".te-toolbar") && ee();
|
|
2057
|
+
},
|
|
2058
|
+
children: [
|
|
2059
|
+
T ? /* @__PURE__ */ i(
|
|
2060
|
+
Ct,
|
|
2061
|
+
{
|
|
2062
|
+
t: _,
|
|
2063
|
+
states: je,
|
|
2064
|
+
canUndo: ze,
|
|
2065
|
+
canRedo: Ke,
|
|
2066
|
+
onCommand: ae,
|
|
2067
|
+
onBlockChange: et,
|
|
2068
|
+
onOpenLink: it,
|
|
2069
|
+
onOpenImage: at,
|
|
2070
|
+
onUndo: ge,
|
|
2071
|
+
onRedo: he,
|
|
2072
|
+
onRememberSelection: ee,
|
|
2073
|
+
sourceMode: B,
|
|
2074
|
+
onToggleSource: ot
|
|
2075
|
+
}
|
|
2076
|
+
) : null,
|
|
2077
|
+
/* @__PURE__ */ d("div", { className: "te-editor-shell", children: [
|
|
2078
|
+
!B && Ze ? /* @__PURE__ */ i("div", { className: "te-placeholder", children: h }) : null,
|
|
2079
|
+
/* @__PURE__ */ i(
|
|
2080
|
+
"div",
|
|
2081
|
+
{
|
|
2082
|
+
ref: u,
|
|
2083
|
+
className: "te-editor",
|
|
2084
|
+
contentEditable: !m && !B,
|
|
2085
|
+
role: "textbox",
|
|
2086
|
+
"aria-multiline": "true",
|
|
2087
|
+
"aria-label": _.editorLabel,
|
|
2088
|
+
"aria-placeholder": h,
|
|
2089
|
+
"aria-hidden": B,
|
|
2090
|
+
suppressContentEditableWarning: !0,
|
|
2091
|
+
style: { minHeight: v, display: B ? "none" : void 0 },
|
|
2092
|
+
dir: k,
|
|
2093
|
+
onInput: Me,
|
|
2094
|
+
onPaste: tt,
|
|
2095
|
+
onKeyDown: rt,
|
|
2096
|
+
onMouseDown: nt,
|
|
2097
|
+
onDoubleClick: lt,
|
|
2098
|
+
onBlur: () => {
|
|
2099
|
+
B || V(z(), { recordHistory: !0 });
|
|
2100
|
+
},
|
|
2101
|
+
onCompositionStart: () => {
|
|
2102
|
+
fe.current = !0;
|
|
2103
|
+
},
|
|
2104
|
+
onCompositionEnd: () => {
|
|
2105
|
+
fe.current = !1, Me();
|
|
2106
|
+
},
|
|
2107
|
+
onMouseUp: N,
|
|
2108
|
+
onKeyUp: N
|
|
2109
|
+
}
|
|
2110
|
+
),
|
|
2111
|
+
B ? /* @__PURE__ */ i(
|
|
2112
|
+
"textarea",
|
|
2113
|
+
{
|
|
2114
|
+
className: "te-source",
|
|
2115
|
+
value: te,
|
|
2116
|
+
onChange: st,
|
|
2117
|
+
onBlur: ct,
|
|
2118
|
+
disabled: m,
|
|
2119
|
+
spellCheck: !1,
|
|
2120
|
+
dir: "ltr",
|
|
2121
|
+
"aria-label": _.sourceLabel,
|
|
2122
|
+
style: { minHeight: v }
|
|
2123
|
+
}
|
|
2124
|
+
) : null
|
|
2125
|
+
] }),
|
|
2126
|
+
/* @__PURE__ */ i(
|
|
2127
|
+
Et,
|
|
2128
|
+
{
|
|
2129
|
+
open: Xe && !B,
|
|
2130
|
+
onClose: () => Ee(!1),
|
|
2131
|
+
t: _,
|
|
2132
|
+
onSubmit: ({ url: o, text: g }) => {
|
|
2133
|
+
Y(() => {
|
|
2134
|
+
ir(u.current, o, g, j.current);
|
|
2135
|
+
});
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
),
|
|
2139
|
+
/* @__PURE__ */ i(
|
|
2140
|
+
At,
|
|
2141
|
+
{
|
|
2142
|
+
open: Ge && !B,
|
|
2143
|
+
onClose: () => Ae(!1),
|
|
2144
|
+
t: _,
|
|
2145
|
+
onSubmitUrl: async ({ url: o, alt: g }) => {
|
|
2146
|
+
Y(() => {
|
|
2147
|
+
const y = Ue(u.current, o, g, j.current);
|
|
2148
|
+
y && (ne(y, u.current, j.current), R.current = y);
|
|
2149
|
+
});
|
|
2150
|
+
},
|
|
2151
|
+
onSubmitFile: async ({ file: o, alt: g }) => {
|
|
2152
|
+
const y = await jt(o, {
|
|
2153
|
+
...I,
|
|
2154
|
+
onUpload: S,
|
|
2155
|
+
language: w,
|
|
2156
|
+
messages: j.current
|
|
2157
|
+
});
|
|
2158
|
+
Y(() => {
|
|
2159
|
+
const H = Ue(u.current, y, g, j.current);
|
|
2160
|
+
H && (ne(H, u.current, j.current), R.current = H);
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
),
|
|
2165
|
+
/* @__PURE__ */ i(
|
|
2166
|
+
wt,
|
|
2167
|
+
{
|
|
2168
|
+
open: Je && !B,
|
|
2169
|
+
initialAlt: Qe,
|
|
2170
|
+
onClose: () => we(!1),
|
|
2171
|
+
t: _,
|
|
2172
|
+
onSubmit: ({ alt: o }) => {
|
|
2173
|
+
var y;
|
|
2174
|
+
const g = R.current;
|
|
2175
|
+
!g || !((y = u.current) != null && y.contains(g)) || (nr(g, o, j.current), V(z()), N());
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
)
|
|
2179
|
+
]
|
|
2180
|
+
}
|
|
2181
|
+
);
|
|
2182
|
+
});
|
|
2183
|
+
export {
|
|
2184
|
+
ur as TeemEditor,
|
|
2185
|
+
$t as createHistory,
|
|
2186
|
+
ur as default,
|
|
2187
|
+
le as flattenStyleSpans,
|
|
2188
|
+
kt as getBlockOptions,
|
|
2189
|
+
yt as getDefaultDir,
|
|
2190
|
+
Oe as getMessages,
|
|
2191
|
+
It as isSafeHref,
|
|
2192
|
+
Rt as isSafeImageSrc,
|
|
2193
|
+
He as locales,
|
|
2194
|
+
jt as processImageUpload,
|
|
2195
|
+
Le as resolveLanguage,
|
|
2196
|
+
W as sanitizeHtml,
|
|
2197
|
+
Ut as uploadDefaults,
|
|
2198
|
+
Pt as validateImageFile
|
|
2199
|
+
};
|
|
2200
|
+
//# sourceMappingURL=teem-editor.js.map
|