forge-edit 0.1.0-beta.2 → 0.1.0-beta.21

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.
@@ -1,1807 +0,0 @@
1
- import { options as e, render as t } from "preact";
2
- import { useEffect as n, useRef as r, useState as i } from "preact/hooks";
3
- import a from "sweetalert2";
4
- //#region src/components/shared/Hooks/options.js
5
- function o(e) {
6
- return {
7
- type: e.getAttribute("type") || "light",
8
- placeholder: e.getAttribute("placeholder") || "",
9
- width: e.getAttribute("width") || "100%",
10
- height: e.getAttribute("height") || "300px",
11
- lang: e.getAttribute("lang") || "en",
12
- dir: e.getAttribute("dir") || "ltr"
13
- };
14
- }
15
- //#endregion
16
- //#region node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
17
- var s = 0;
18
- Array.isArray;
19
- function c(t, n, r, i, a, o) {
20
- n ||= {};
21
- var c, l, u = n;
22
- if ("ref" in u) for (l in u = {}, n) l == "ref" ? c = n[l] : u[l] = n[l];
23
- var d = {
24
- type: t,
25
- props: u,
26
- key: r,
27
- ref: c,
28
- __k: null,
29
- __: null,
30
- __b: 0,
31
- __e: null,
32
- __c: null,
33
- constructor: void 0,
34
- __v: --s,
35
- __i: -1,
36
- __u: 0,
37
- __source: a,
38
- __self: o
39
- };
40
- if (typeof t == "function" && (c = t.defaultProps)) for (l in c) u[l] === void 0 && (u[l] = c[l]);
41
- return e.vnode && e.vnode(d), d;
42
- }
43
- //#endregion
44
- //#region src/components/shared/toolbar/Style/Components/StyleToolbar.jsx
45
- function l() {
46
- return /* @__PURE__ */ c("div", {
47
- className: "forge-toolbar-group forge-toolbar-style",
48
- children: /* @__PURE__ */ c("div", {
49
- className: "forge-toolbar-group",
50
- children: [/* @__PURE__ */ c("button", {
51
- type: "button",
52
- className: "forge-toolbar-button",
53
- "data-command": "style",
54
- "aria-label": "Style",
55
- children: [/* @__PURE__ */ c("span", {
56
- className: "forge-icon",
57
- children: "✦"
58
- }), /* @__PURE__ */ c("span", {
59
- className: "forge-tooltip",
60
- "data-i18n": "style"
61
- })]
62
- }), /* @__PURE__ */ c("div", {
63
- className: "forge-toolbar-dropdown forge-dropdown-style",
64
- role: "list",
65
- "aria-label": "Style",
66
- children: [
67
- /* @__PURE__ */ c("a", {
68
- className: "forge-dropdown-item",
69
- href: "#",
70
- "data-value": "p",
71
- role: "listitem",
72
- children: /* @__PURE__ */ c("p", { "data-i18n": "normal" })
73
- }),
74
- /* @__PURE__ */ c("a", {
75
- className: "forge-dropdown-item",
76
- href: "#",
77
- "data-value": "blockquote",
78
- role: "listitem",
79
- children: /* @__PURE__ */ c("blockquote", { "data-i18n": "blockquote" })
80
- }),
81
- /* @__PURE__ */ c("a", {
82
- className: "forge-dropdown-item",
83
- href: "#",
84
- "data-value": "pre",
85
- role: "listitem",
86
- children: /* @__PURE__ */ c("pre", { "data-i18n": "code" })
87
- }),
88
- /* @__PURE__ */ c("a", {
89
- className: "forge-dropdown-item",
90
- href: "#",
91
- "data-value": "h1",
92
- role: "listitem",
93
- children: /* @__PURE__ */ c("h1", { "data-i18n": "header1" })
94
- }),
95
- /* @__PURE__ */ c("a", {
96
- className: "forge-dropdown-item",
97
- href: "#",
98
- "data-value": "h2",
99
- role: "listitem",
100
- children: /* @__PURE__ */ c("h2", { "data-i18n": "header2" })
101
- }),
102
- /* @__PURE__ */ c("a", {
103
- className: "forge-dropdown-item",
104
- href: "#",
105
- "data-value": "h3",
106
- role: "listitem",
107
- children: /* @__PURE__ */ c("h3", { "data-i18n": "header3" })
108
- }),
109
- /* @__PURE__ */ c("a", {
110
- className: "forge-dropdown-item",
111
- href: "#",
112
- "data-value": "h4",
113
- role: "listitem",
114
- children: /* @__PURE__ */ c("h4", { "data-i18n": "header4" })
115
- }),
116
- /* @__PURE__ */ c("a", {
117
- className: "forge-dropdown-item",
118
- href: "#",
119
- "data-value": "h5",
120
- role: "listitem",
121
- children: /* @__PURE__ */ c("h5", { "data-i18n": "header5" })
122
- }),
123
- /* @__PURE__ */ c("a", {
124
- className: "forge-dropdown-item",
125
- href: "#",
126
- "data-value": "h6",
127
- role: "listitem",
128
- children: /* @__PURE__ */ c("h6", { "data-i18n": "header6" })
129
- })
130
- ]
131
- })]
132
- })
133
- });
134
- }
135
- //#endregion
136
- //#region src/components/shared/toolbar/Style/Components/index.jsx
137
- function u() {
138
- return l();
139
- }
140
- //#endregion
141
- //#region src/components/shared/toolbar/font/Components/FontToolbar.jsx
142
- function d({ onCommand: e }) {
143
- return /* @__PURE__ */ c("div", {
144
- className: "forge-toolbar-group forge-toolbar-font",
145
- children: [
146
- /* @__PURE__ */ c("button", {
147
- type: "button",
148
- className: "forge-toolbar-button forge-btn-bold",
149
- onClick: () => e("bold"),
150
- "aria-label": "Bold",
151
- children: [/* @__PURE__ */ c("strong", { children: "B" }), /* @__PURE__ */ c("span", {
152
- className: "forge-tooltip",
153
- "data-i18n": "bold"
154
- })]
155
- }),
156
- /* @__PURE__ */ c("button", {
157
- type: "button",
158
- className: "forge-toolbar-button forge-btn-underline",
159
- onClick: () => e("underline"),
160
- "aria-label": "Underline",
161
- children: [/* @__PURE__ */ c("u", { children: "U" }), /* @__PURE__ */ c("span", {
162
- className: "forge-tooltip",
163
- "data-i18n": "underline"
164
- })]
165
- }),
166
- /* @__PURE__ */ c("button", {
167
- type: "button",
168
- className: "forge-toolbar-button",
169
- onClick: () => e("removeFormat"),
170
- "aria-label": "Remove Font Style",
171
- children: [/* @__PURE__ */ c("span", { children: "⌫" }), /* @__PURE__ */ c("span", {
172
- className: "forge-tooltip",
173
- "data-i18n": "removeFormat"
174
- })]
175
- })
176
- ]
177
- });
178
- }
179
- //#endregion
180
- //#region src/components/shared/toolbar/font/Hooks/fontLogic.jsx
181
- function f() {
182
- return { executeCommand: (e) => {
183
- document.execCommand(e, !1, null);
184
- } };
185
- }
186
- //#endregion
187
- //#region src/components/shared/toolbar/font/Components/index.jsx
188
- function p() {
189
- let { executeCommand: e } = f();
190
- return /* @__PURE__ */ c(d, { onCommand: e });
191
- }
192
- //#endregion
193
- //#region src/components/shared/toolbar/Hooks/dropdown.js
194
- function m(e, t) {
195
- function n() {
196
- t.classList.remove("is-open"), e.classList.remove("is-active"), document.removeEventListener("click", r);
197
- }
198
- function r(r) {
199
- !t.contains(r.target) && r.target !== e && n();
200
- }
201
- function i(n) {
202
- n.stopPropagation();
203
- let i = t.classList.contains("is-open");
204
- document.querySelectorAll(".forge-toolbar-dropdown.is-open").forEach((e) => {
205
- e.classList.remove("is-open");
206
- }), document.querySelectorAll(".forge-toolbar-button.is-active").forEach((e) => {
207
- e.classList.remove("is-active");
208
- }), i || (t.classList.add("is-open"), e.classList.add("is-active"), document.addEventListener("click", r));
209
- }
210
- return e.addEventListener("click", i), function() {
211
- e.removeEventListener("click", i), document.removeEventListener("click", r);
212
- };
213
- }
214
- //#endregion
215
- //#region src/components/shared/toolbar/FontName/Components/FontNameToolbar.jsx
216
- var h = [
217
- "Arial",
218
- "Arial Black",
219
- "Comic Sans MS",
220
- "Courier New",
221
- "Helvetica",
222
- "Impact",
223
- "Tahoma",
224
- "Times New Roman",
225
- "Verdana",
226
- "Nunito Sans",
227
- "Segoe UI"
228
- ];
229
- function g({ logic: e }) {
230
- let { currentFont: t, applyFont: i } = e, a = r(null), o = r(null);
231
- n(() => {
232
- if (a.current && o.current) return m(a.current, o.current);
233
- }, []);
234
- let s = (e) => {
235
- i(e), o.current && o.current.classList.remove("is-open"), a.current && a.current.classList.remove("is-active");
236
- };
237
- return /* @__PURE__ */ c("div", {
238
- className: "forge-toolbar-group forge-toolbar-fontname",
239
- children: [/* @__PURE__ */ c("button", {
240
- ref: a,
241
- type: "button",
242
- className: "forge-toolbar-button forge-fontname-button",
243
- "aria-label": "Font Family",
244
- children: [/* @__PURE__ */ c("span", {
245
- className: "forge-current-fontname",
246
- children: t
247
- }), /* @__PURE__ */ c("span", {
248
- className: "forge-tooltip",
249
- "data-i18n": "fontFamily",
250
- children: "Font Family"
251
- })]
252
- }), /* @__PURE__ */ c("div", {
253
- ref: o,
254
- className: "forge-toolbar-dropdown forge-dropdown-fontname",
255
- role: "list",
256
- "aria-label": "Font Family",
257
- children: h.map((e) => /* @__PURE__ */ c("a", {
258
- className: "forge-dropdown-item",
259
- href: "#",
260
- "data-value": e,
261
- role: "listitem",
262
- style: { fontFamily: e },
263
- onClick: (t) => {
264
- t.preventDefault(), s(e);
265
- },
266
- children: e
267
- }, e))
268
- })]
269
- });
270
- }
271
- //#endregion
272
- //#region src/components/shared/toolbar/FontName/Hooks/fontNameLogic.jsx
273
- function _() {
274
- let [e, t] = i("Nunito Sans");
275
- return {
276
- currentFont: e,
277
- applyFont: (e) => {
278
- document.execCommand("fontName", !1, e), t(e);
279
- }
280
- };
281
- }
282
- //#endregion
283
- //#region src/components/shared/toolbar/FontName/Components/index.jsx
284
- function v() {
285
- return /* @__PURE__ */ c(g, { logic: _() });
286
- }
287
- //#endregion
288
- //#region src/components/shared/toolbar/Color/Components/colorPalette.jsx
289
- var y = [
290
- [
291
- "#000000",
292
- "#424242",
293
- "#636363",
294
- "#9C9C94",
295
- "#CEC6CE",
296
- "#EFEFEF",
297
- "#F7F7F7",
298
- "#FFFFFF"
299
- ],
300
- [
301
- "#FF0000",
302
- "#FF9C00",
303
- "#FFFF00",
304
- "#00FF00",
305
- "#00FFFF",
306
- "#0000FF",
307
- "#9C00FF",
308
- "#FF00FF"
309
- ],
310
- [
311
- "#F7C6CE",
312
- "#FFE7CE",
313
- "#FFEFC6",
314
- "#D6EFD6",
315
- "#CEDEE7",
316
- "#CEE7F7",
317
- "#D6D6E7",
318
- "#E7D6DE"
319
- ],
320
- [
321
- "#E79C9C",
322
- "#FFC69C",
323
- "#FFE79C",
324
- "#B5D6A5",
325
- "#A5C6CE",
326
- "#9CC6EF",
327
- "#B5A5D6",
328
- "#D6A5BD"
329
- ],
330
- [
331
- "#E76363",
332
- "#F7AD6B",
333
- "#FFD663",
334
- "#94BD7B",
335
- "#73A5AD",
336
- "#6BADDE",
337
- "#8C7BC6",
338
- "#C67BA5"
339
- ],
340
- [
341
- "#CE0000",
342
- "#E79439",
343
- "#EFC631",
344
- "#6BA54A",
345
- "#4A7B8C",
346
- "#3984C6",
347
- "#634AA5",
348
- "#A54A7B"
349
- ],
350
- [
351
- "#9C0000",
352
- "#B56308",
353
- "#BD9400",
354
- "#397B21",
355
- "#104A5A",
356
- "#085294",
357
- "#311873",
358
- "#731842"
359
- ],
360
- [
361
- "#630000",
362
- "#7B3900",
363
- "#846300",
364
- "#295218",
365
- "#083139",
366
- "#003163",
367
- "#21104A",
368
- "#4A1031"
369
- ]
370
- ];
371
- function b({ event: e, onApply: t }) {
372
- return /* @__PURE__ */ c("div", {
373
- className: "forge-color-palette",
374
- children: y.map((n, r) => /* @__PURE__ */ c("div", {
375
- className: "forge-color-row",
376
- children: n.map((n) => /* @__PURE__ */ c("button", {
377
- type: "button",
378
- className: "forge-color-button",
379
- style: { backgroundColor: n },
380
- onMouseDown: (e) => e.preventDefault(),
381
- onClick: () => t(e, n),
382
- "aria-label": n
383
- }, n))
384
- }, r))
385
- });
386
- }
387
- //#endregion
388
- //#region src/components/shared/toolbar/Color/Components/ColorToolbar.jsx
389
- function x({ logic: e }) {
390
- let { applyColor: t, applyRecentColor: i, resetColor: a, recentForeColor: o, recentBackColor: s } = e, l = r(null), u = r(null), d = r(null), f = r(null);
391
- return n(() => {
392
- if (l.current && u.current) return m(l.current, u.current);
393
- }, []), n(() => {
394
- if (d.current && f.current) return m(d.current, f.current);
395
- }, []), /* @__PURE__ */ c("div", {
396
- className: "forge-toolbar-group forge-toolbar-color",
397
- children: [/* @__PURE__ */ c("div", {
398
- className: "forge-color-item",
399
- children: [/* @__PURE__ */ c("div", {
400
- className: "forge-color-button-group",
401
- children: [/* @__PURE__ */ c("button", {
402
- type: "button",
403
- className: "forge-color-main forge-toolbar-button",
404
- onMouseDown: (e) => e.preventDefault(),
405
- onClick: () => i("foreColor"),
406
- "aria-label": "Apply text color",
407
- children: [/* @__PURE__ */ c("span", {
408
- className: "forge-recent-color",
409
- style: {
410
- backgroundColor: "transparent",
411
- color: o
412
- },
413
- children: "A"
414
- }), /* @__PURE__ */ c("span", {
415
- className: "forge-tooltip",
416
- "data-i18n": "recentColor",
417
- children: "Recent Color"
418
- })]
419
- }), /* @__PURE__ */ c("button", {
420
- ref: l,
421
- type: "button",
422
- className: "forge-color-dropdown-btn forge-toolbar-button",
423
- onMouseDown: (e) => e.preventDefault(),
424
- "aria-label": "More text colors",
425
- children: ["▼", /* @__PURE__ */ c("span", {
426
- className: "forge-tooltip",
427
- "data-i18n": "moreColor",
428
- children: "More Color"
429
- })]
430
- })]
431
- }), /* @__PURE__ */ c("div", {
432
- ref: u,
433
- className: "forge-toolbar-dropdown forge-dropdown-color",
434
- children: /* @__PURE__ */ c("div", {
435
- className: "forge-color-section",
436
- children: [/* @__PURE__ */ c("div", {
437
- className: "forge-color-section-header",
438
- children: [/* @__PURE__ */ c("span", {
439
- className: "forge-color-title",
440
- children: "Text Color"
441
- }), /* @__PURE__ */ c("button", {
442
- type: "button",
443
- className: "forge-color-reset",
444
- onMouseDown: (e) => e.preventDefault(),
445
- onClick: () => {
446
- a("foreColor"), u.current && u.current.classList.remove("is-open"), l.current && l.current.classList.remove("is-active");
447
- },
448
- children: "Reset"
449
- })]
450
- }), /* @__PURE__ */ c(b, {
451
- event: "foreColor",
452
- onApply: (e, n) => {
453
- t(e, n), u.current && u.current.classList.remove("is-open"), l.current && l.current.classList.remove("is-active");
454
- }
455
- })]
456
- })
457
- })]
458
- }), /* @__PURE__ */ c("div", {
459
- className: "forge-color-item",
460
- children: [/* @__PURE__ */ c("div", {
461
- className: "forge-color-button-group",
462
- children: [/* @__PURE__ */ c("button", {
463
- type: "button",
464
- className: "forge-color-main forge-toolbar-button",
465
- onMouseDown: (e) => e.preventDefault(),
466
- onClick: () => i("backColor"),
467
- "aria-label": "Apply background color",
468
- children: [/* @__PURE__ */ c("span", {
469
- className: "forge-recent-color",
470
- style: {
471
- backgroundColor: s,
472
- color: "#000"
473
- },
474
- children: "A"
475
- }), /* @__PURE__ */ c("span", {
476
- className: "forge-tooltip",
477
- "data-i18n": "recentBackColor",
478
- children: "Recent Background Color"
479
- })]
480
- }), /* @__PURE__ */ c("button", {
481
- ref: d,
482
- type: "button",
483
- className: "forge-color-dropdown-btn forge-toolbar-button",
484
- onMouseDown: (e) => e.preventDefault(),
485
- "aria-label": "More background colors",
486
- children: ["▼", /* @__PURE__ */ c("span", {
487
- className: "forge-tooltip",
488
- "data-i18n": "moreBackColor",
489
- children: "More Background Colors"
490
- })]
491
- })]
492
- }), /* @__PURE__ */ c("div", {
493
- ref: f,
494
- className: "forge-toolbar-dropdown forge-dropdown-color",
495
- children: /* @__PURE__ */ c("div", {
496
- className: "forge-color-section",
497
- children: [/* @__PURE__ */ c("div", {
498
- className: "forge-color-section-header",
499
- children: [/* @__PURE__ */ c("span", {
500
- className: "forge-color-title",
501
- children: "Background Color"
502
- }), /* @__PURE__ */ c("button", {
503
- type: "button",
504
- className: "forge-color-reset",
505
- onMouseDown: (e) => e.preventDefault(),
506
- onClick: () => {
507
- a("backColor"), f.current && f.current.classList.remove("is-open"), d.current && d.current.classList.remove("is-active");
508
- },
509
- children: "Transparent"
510
- })]
511
- }), /* @__PURE__ */ c(b, {
512
- event: "backColor",
513
- onApply: (e, n) => {
514
- t(e, n), f.current && f.current.classList.remove("is-open"), d.current && d.current.classList.remove("is-active");
515
- }
516
- })]
517
- })
518
- })]
519
- })]
520
- });
521
- }
522
- //#endregion
523
- //#region src/components/shared/toolbar/Color/Hooks/colorUtils.jsx
524
- function S(e) {
525
- let t = document.createElement("span");
526
- t.style.color = e, document.body.appendChild(t);
527
- let n = window.getComputedStyle(t).color;
528
- return document.body.removeChild(t), n;
529
- }
530
- function C(e, t) {
531
- let n = e;
532
- for (; n && n !== document.body;) {
533
- if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "SPAN" && n.style.color && S(n.style.color) === t) return n;
534
- n = n.parentElement;
535
- }
536
- return null;
537
- }
538
- //#endregion
539
- //#region src/components/shared/toolbar/Color/Hooks/usePenMode.jsx
540
- function w(e, t) {
541
- n(() => {
542
- function n(n) {
543
- if (n.inputType !== "insertText" || !n.data || !e.current) return;
544
- let r = n.target;
545
- if (!r || !r.classList || !r.classList.contains(t)) return;
546
- let i = window.getSelection();
547
- if (!i || !i.rangeCount) return;
548
- let a = i.getRangeAt(0);
549
- if (!a.collapsed) return;
550
- let o = S(e.current), s = a.startContainer;
551
- s.nodeType === Node.TEXT_NODE && (s = s.parentElement);
552
- let c = C(s, o);
553
- if (n.preventDefault(), c) {
554
- let e = document.createTextNode(n.data);
555
- a.insertNode(e), a.setStartAfter(e), a.collapse(!0), i.removeAllRanges(), i.addRange(a);
556
- return;
557
- }
558
- let l = document.createElement("span");
559
- l.style.color = e.current, l.textContent = n.data, a.deleteContents(), a.insertNode(l);
560
- let u = document.createRange();
561
- u.selectNodeContents(l), u.collapse(!1), i.removeAllRanges(), i.addRange(u);
562
- }
563
- return document.addEventListener("beforeinput", n, !0), () => document.removeEventListener("beforeinput", n, !0);
564
- }, []);
565
- }
566
- //#endregion
567
- //#region src/components/shared/toolbar/Color/Hooks/useForeColor.jsx
568
- function T(e = "forge-editor__content") {
569
- let [t, n] = i("#000000"), a = r(null);
570
- w(a, e);
571
- let o = (e) => {
572
- let t = window.getSelection();
573
- t && t.rangeCount && !t.getRangeAt(0).collapsed && (document.execCommand("styleWithCSS", !1, !0), document.execCommand("foreColor", !1, e)), a.current = e, n(e);
574
- };
575
- return {
576
- recentForeColor: t,
577
- applyForeColor: o,
578
- applyRecentForeColor: () => {
579
- o(t);
580
- },
581
- resetForeColor: () => {
582
- document.execCommand("styleWithCSS", !1, !0), document.execCommand("removeFormat", !1, null), a.current = null, n("#000000");
583
- }
584
- };
585
- }
586
- //#endregion
587
- //#region src/components/shared/toolbar/Color/Hooks/useBackColor.jsx
588
- function E() {
589
- let [e, t] = i("#FFFF00");
590
- return {
591
- recentBackColor: e,
592
- applyBackColor: (e) => {
593
- document.execCommand("styleWithCSS", !1, !0), document.execCommand("backColor", !1, e), t(e);
594
- },
595
- applyRecentBackColor: () => {
596
- document.execCommand("styleWithCSS", !1, !0), document.execCommand("backColor", !1, e);
597
- },
598
- resetBackColor: () => {
599
- document.execCommand("styleWithCSS", !1, !0), document.execCommand("backColor", !1, "transparent"), t("transparent");
600
- }
601
- };
602
- }
603
- //#endregion
604
- //#region src/components/shared/toolbar/Color/Hooks/colorLogic.jsx
605
- function D() {
606
- let e = T(), t = E();
607
- return {
608
- applyColor: (n, r) => {
609
- n === "foreColor" ? e.applyForeColor(r) : n === "backColor" && t.applyBackColor(r);
610
- },
611
- applyRecentColor: (n) => {
612
- n === "foreColor" ? e.applyRecentForeColor() : n === "backColor" && t.applyRecentBackColor();
613
- },
614
- resetColor: (n) => {
615
- n === "foreColor" ? e.resetForeColor() : n === "backColor" && t.resetBackColor();
616
- },
617
- recentForeColor: e.recentForeColor,
618
- recentBackColor: t.recentBackColor
619
- };
620
- }
621
- //#endregion
622
- //#region src/components/shared/toolbar/Color/Components/index.jsx
623
- function O() {
624
- return console.log("[CreateColorToolbar] Rendering ColorToolbar"), /* @__PURE__ */ c(x, { logic: D() });
625
- }
626
- //#endregion
627
- //#region src/components/shared/toolbar/Paragraph/Components/ParagraphToolbar.jsx
628
- function ee({ logic: e }) {
629
- let { execCommand: t } = e, i = r(null), a = r(null);
630
- return n(() => {
631
- if (i.current && a.current) return m(i.current, a.current);
632
- }, []), /* @__PURE__ */ c("div", {
633
- className: "forge-toolbar-group forge-toolbar-paragraph",
634
- children: [
635
- /* @__PURE__ */ c("button", {
636
- type: "button",
637
- className: "forge-toolbar-button",
638
- onClick: () => t("insertUnorderedList"),
639
- "aria-label": "Unordered list",
640
- children: [/* @__PURE__ */ c("span", {
641
- className: "forge-toolbar-icon",
642
- children: /* @__PURE__ */ c("svg", {
643
- viewBox: "0 0 20 20",
644
- width: "16",
645
- height: "16",
646
- children: [
647
- /* @__PURE__ */ c("circle", {
648
- cx: "2.5",
649
- cy: "4",
650
- r: "1.5"
651
- }),
652
- /* @__PURE__ */ c("circle", {
653
- cx: "2.5",
654
- cy: "10",
655
- r: "1.5"
656
- }),
657
- /* @__PURE__ */ c("circle", {
658
- cx: "2.5",
659
- cy: "16",
660
- r: "1.5"
661
- }),
662
- /* @__PURE__ */ c("rect", {
663
- x: "7",
664
- y: "3",
665
- width: "12",
666
- height: "2",
667
- rx: "1"
668
- }),
669
- /* @__PURE__ */ c("rect", {
670
- x: "7",
671
- y: "9",
672
- width: "12",
673
- height: "2",
674
- rx: "1"
675
- }),
676
- /* @__PURE__ */ c("rect", {
677
- x: "7",
678
- y: "15",
679
- width: "12",
680
- height: "2",
681
- rx: "1"
682
- })
683
- ]
684
- })
685
- }), /* @__PURE__ */ c("span", {
686
- className: "forge-tooltip",
687
- "data-i18n": "unorderedList",
688
- children: "Bullet list"
689
- })]
690
- }),
691
- /* @__PURE__ */ c("button", {
692
- type: "button",
693
- className: "forge-toolbar-button",
694
- onClick: () => t("insertOrderedList"),
695
- "aria-label": "Ordered list",
696
- children: [/* @__PURE__ */ c("span", {
697
- className: "forge-toolbar-icon",
698
- children: /* @__PURE__ */ c("svg", {
699
- viewBox: "0 0 20 20",
700
- width: "16",
701
- height: "16",
702
- children: [
703
- /* @__PURE__ */ c("rect", {
704
- x: "7",
705
- y: "3",
706
- width: "12",
707
- height: "2",
708
- rx: "1"
709
- }),
710
- /* @__PURE__ */ c("rect", {
711
- x: "7",
712
- y: "9",
713
- width: "12",
714
- height: "2",
715
- rx: "1"
716
- }),
717
- /* @__PURE__ */ c("rect", {
718
- x: "7",
719
- y: "15",
720
- width: "12",
721
- height: "2",
722
- rx: "1"
723
- }),
724
- /* @__PURE__ */ c("path", {
725
- d: "M 1.5 4.5 L 3.5 3 L 3.5 10 M 2 10 L 5 10",
726
- fill: "none",
727
- stroke: "#000",
728
- strokeWidth: "1.8",
729
- strokeLinecap: "round",
730
- strokeLinejoin: "round"
731
- }),
732
- /* @__PURE__ */ c("path", {
733
- d: "M 1.5 14 C 1.5 12.8 4.5 12.8 4.5 14.5 C 4.5 16 1.5 16.5 1.5 18 L 5 18",
734
- fill: "none",
735
- stroke: "#000",
736
- strokeWidth: "1.8",
737
- strokeLinecap: "round",
738
- strokeLinejoin: "round"
739
- })
740
- ]
741
- })
742
- }), /* @__PURE__ */ c("span", {
743
- className: "forge-tooltip",
744
- "data-i18n": "orderedList",
745
- children: "Numbered list"
746
- })]
747
- }),
748
- /* @__PURE__ */ c("button", {
749
- ref: i,
750
- type: "button",
751
- className: "forge-toolbar-button",
752
- "aria-label": "Paragraph",
753
- children: [/* @__PURE__ */ c("span", {
754
- className: "forge-toolbar-icon",
755
- children: /* @__PURE__ */ c("svg", {
756
- viewBox: "0 0 20 20",
757
- width: "16",
758
- height: "16",
759
- children: [
760
- /* @__PURE__ */ c("rect", {
761
- x: "1",
762
- y: "3",
763
- width: "18",
764
- height: "2",
765
- rx: "1"
766
- }),
767
- /* @__PURE__ */ c("rect", {
768
- x: "1",
769
- y: "9",
770
- width: "18",
771
- height: "2",
772
- rx: "1"
773
- }),
774
- /* @__PURE__ */ c("rect", {
775
- x: "1",
776
- y: "15",
777
- width: "12",
778
- height: "2",
779
- rx: "1"
780
- })
781
- ]
782
- })
783
- }), /* @__PURE__ */ c("span", {
784
- className: "forge-tooltip",
785
- "data-i18n": "paragraph",
786
- children: "Paragraph"
787
- })]
788
- }),
789
- /* @__PURE__ */ c("div", {
790
- ref: a,
791
- className: "forge-toolbar-dropdown forge-dropdown-paragraph",
792
- role: "list",
793
- "aria-label": "Paragraph options",
794
- children: [/* @__PURE__ */ c("div", {
795
- className: "forge-toolbar-group forge-toolbar-align",
796
- children: [
797
- /* @__PURE__ */ c("button", {
798
- type: "button",
799
- className: "forge-toolbar-button",
800
- onClick: () => t("justifyLeft"),
801
- "aria-label": "Align left",
802
- children: [/* @__PURE__ */ c("span", {
803
- className: "forge-toolbar-icon",
804
- children: /* @__PURE__ */ c("svg", {
805
- viewBox: "0 0 20 20",
806
- width: "16",
807
- height: "16",
808
- children: [
809
- /* @__PURE__ */ c("rect", {
810
- x: "1",
811
- y: "3",
812
- width: "18",
813
- height: "2",
814
- rx: "1"
815
- }),
816
- /* @__PURE__ */ c("rect", {
817
- x: "1",
818
- y: "9",
819
- width: "12",
820
- height: "2",
821
- rx: "1"
822
- }),
823
- /* @__PURE__ */ c("rect", {
824
- x: "1",
825
- y: "15",
826
- width: "18",
827
- height: "2",
828
- rx: "1"
829
- })
830
- ]
831
- })
832
- }), /* @__PURE__ */ c("span", {
833
- className: "forge-tooltip",
834
- "data-i18n": "alignLeft",
835
- children: "Left"
836
- })]
837
- }),
838
- /* @__PURE__ */ c("button", {
839
- type: "button",
840
- className: "forge-toolbar-button",
841
- onClick: () => t("justifyCenter"),
842
- "aria-label": "Align center",
843
- children: [/* @__PURE__ */ c("span", {
844
- className: "forge-toolbar-icon",
845
- children: /* @__PURE__ */ c("svg", {
846
- viewBox: "0 0 20 20",
847
- width: "16",
848
- height: "16",
849
- children: [
850
- /* @__PURE__ */ c("rect", {
851
- x: "1",
852
- y: "3",
853
- width: "18",
854
- height: "2",
855
- rx: "1"
856
- }),
857
- /* @__PURE__ */ c("rect", {
858
- x: "4",
859
- y: "9",
860
- width: "12",
861
- height: "2",
862
- rx: "1"
863
- }),
864
- /* @__PURE__ */ c("rect", {
865
- x: "1",
866
- y: "15",
867
- width: "18",
868
- height: "2",
869
- rx: "1"
870
- })
871
- ]
872
- })
873
- }), /* @__PURE__ */ c("span", {
874
- className: "forge-tooltip",
875
- "data-i18n": "alignCenter",
876
- children: "Center"
877
- })]
878
- }),
879
- /* @__PURE__ */ c("button", {
880
- type: "button",
881
- className: "forge-toolbar-button",
882
- onClick: () => t("justifyRight"),
883
- "aria-label": "Align right",
884
- children: [/* @__PURE__ */ c("span", {
885
- className: "forge-toolbar-icon",
886
- children: /* @__PURE__ */ c("svg", {
887
- viewBox: "0 0 20 20",
888
- width: "16",
889
- height: "16",
890
- children: [
891
- /* @__PURE__ */ c("rect", {
892
- x: "1",
893
- y: "3",
894
- width: "18",
895
- height: "2",
896
- rx: "1"
897
- }),
898
- /* @__PURE__ */ c("rect", {
899
- x: "7",
900
- y: "9",
901
- width: "12",
902
- height: "2",
903
- rx: "1"
904
- }),
905
- /* @__PURE__ */ c("rect", {
906
- x: "1",
907
- y: "15",
908
- width: "18",
909
- height: "2",
910
- rx: "1"
911
- })
912
- ]
913
- })
914
- }), /* @__PURE__ */ c("span", {
915
- className: "forge-tooltip",
916
- "data-i18n": "alignRight",
917
- children: "Right"
918
- })]
919
- }),
920
- /* @__PURE__ */ c("button", {
921
- type: "button",
922
- className: "forge-toolbar-button",
923
- onClick: () => t("justifyFull"),
924
- "aria-label": "Justify",
925
- children: [/* @__PURE__ */ c("span", {
926
- className: "forge-toolbar-icon",
927
- children: /* @__PURE__ */ c("svg", {
928
- viewBox: "0 0 20 20",
929
- width: "16",
930
- height: "16",
931
- children: [
932
- /* @__PURE__ */ c("rect", {
933
- x: "1",
934
- y: "3",
935
- width: "18",
936
- height: "2",
937
- rx: "1"
938
- }),
939
- /* @__PURE__ */ c("rect", {
940
- x: "1",
941
- y: "9",
942
- width: "18",
943
- height: "2",
944
- rx: "1"
945
- }),
946
- /* @__PURE__ */ c("rect", {
947
- x: "1",
948
- y: "15",
949
- width: "18",
950
- height: "2",
951
- rx: "1"
952
- })
953
- ]
954
- })
955
- }), /* @__PURE__ */ c("span", {
956
- className: "forge-tooltip",
957
- "data-i18n": "justify",
958
- children: "Justify"
959
- })]
960
- })
961
- ]
962
- }), /* @__PURE__ */ c("div", {
963
- className: "forge-toolbar-group forge-toolbar-list",
964
- children: [/* @__PURE__ */ c("button", {
965
- type: "button",
966
- className: "forge-toolbar-button",
967
- onClick: () => t("outdent"),
968
- "aria-label": "Outdent",
969
- children: [/* @__PURE__ */ c("span", {
970
- className: "forge-toolbar-icon",
971
- children: /* @__PURE__ */ c("svg", {
972
- viewBox: "0 0 20 20",
973
- width: "16",
974
- height: "16",
975
- fill: "none",
976
- stroke: "currentColor",
977
- strokeWidth: "2",
978
- strokeLinecap: "round",
979
- strokeLinejoin: "round",
980
- children: [
981
- /* @__PURE__ */ c("line", {
982
- x1: "9",
983
- y1: "3",
984
- x2: "19",
985
- y2: "3"
986
- }),
987
- /* @__PURE__ */ c("line", {
988
- x1: "9",
989
- y1: "10",
990
- x2: "19",
991
- y2: "10"
992
- }),
993
- /* @__PURE__ */ c("line", {
994
- x1: "9",
995
- y1: "17",
996
- x2: "19",
997
- y2: "17"
998
- }),
999
- /* @__PURE__ */ c("polyline", { points: "6,7 2,10 6,13" })
1000
- ]
1001
- })
1002
- }), /* @__PURE__ */ c("span", {
1003
- className: "forge-tooltip",
1004
- "data-i18n": "outdent",
1005
- children: "Outdent"
1006
- })]
1007
- }), /* @__PURE__ */ c("button", {
1008
- type: "button",
1009
- className: "forge-toolbar-button",
1010
- onClick: () => t("indent"),
1011
- "aria-label": "Indent",
1012
- children: [/* @__PURE__ */ c("span", {
1013
- className: "forge-toolbar-icon",
1014
- children: /* @__PURE__ */ c("svg", {
1015
- viewBox: "0 0 20 20",
1016
- width: "16",
1017
- height: "16",
1018
- fill: "none",
1019
- stroke: "currentColor",
1020
- strokeWidth: "2",
1021
- strokeLinecap: "round",
1022
- strokeLinejoin: "round",
1023
- children: [
1024
- /* @__PURE__ */ c("line", {
1025
- x1: "9",
1026
- y1: "3",
1027
- x2: "19",
1028
- y2: "3"
1029
- }),
1030
- /* @__PURE__ */ c("line", {
1031
- x1: "9",
1032
- y1: "10",
1033
- x2: "19",
1034
- y2: "10"
1035
- }),
1036
- /* @__PURE__ */ c("line", {
1037
- x1: "9",
1038
- y1: "17",
1039
- x2: "19",
1040
- y2: "17"
1041
- }),
1042
- /* @__PURE__ */ c("polyline", { points: "2,7 6,10 2,13" })
1043
- ]
1044
- })
1045
- }), /* @__PURE__ */ c("span", {
1046
- className: "forge-tooltip",
1047
- "data-i18n": "indent",
1048
- children: "Indent"
1049
- })]
1050
- })]
1051
- })]
1052
- })
1053
- ]
1054
- });
1055
- }
1056
- //#endregion
1057
- //#region src/components/shared/toolbar/Paragraph/Hooks/paragraphLogic.jsx
1058
- function k() {
1059
- return { execCommand: (e) => {
1060
- document.execCommand(e, !1, null);
1061
- } };
1062
- }
1063
- //#endregion
1064
- //#region src/components/shared/toolbar/Paragraph/Components/index.jsx
1065
- function A() {
1066
- return /* @__PURE__ */ c(ee, { logic: k() });
1067
- }
1068
- //#endregion
1069
- //#region src/components/shared/toolbar/Table/Components/TableToolbar.jsx
1070
- var j = 10;
1071
- function M({ logic: e }) {
1072
- let { insertTable: t } = e, [a, o] = i(1), [s, l] = i(1), u = r(null), d = r(null), f = r(null);
1073
- n(() => {
1074
- if (u.current && d.current) return m(u.current, d.current);
1075
- }, []);
1076
- let p = (e) => {
1077
- if (!f.current) return;
1078
- let t = f.current.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top, i = t.width / j, a = Math.min(Math.floor(n / i) + 1, j), s = Math.min(Math.floor(r / i) + 1, j);
1079
- l(a), o(s);
1080
- }, h = () => {
1081
- o(1), l(1);
1082
- }, g = () => {
1083
- t(a, s), d.current && d.current.classList.remove("is-open"), u.current && u.current.classList.remove("is-active"), o(1), l(1);
1084
- }, _ = s / j * 100, v = a / j * 100;
1085
- return /* @__PURE__ */ c("div", {
1086
- className: "forge-toolbar-group forge-toolbar-table",
1087
- children: [/* @__PURE__ */ c("button", {
1088
- ref: u,
1089
- type: "button",
1090
- className: "forge-toolbar-button",
1091
- "aria-label": "Table",
1092
- children: [/* @__PURE__ */ c("span", {
1093
- className: "forge-toolbar-icon",
1094
- children: "▦"
1095
- }), /* @__PURE__ */ c("span", {
1096
- className: "forge-tooltip",
1097
- "data-i18n": "table",
1098
- children: "Table"
1099
- })]
1100
- }), /* @__PURE__ */ c("div", {
1101
- ref: d,
1102
- className: "forge-toolbar-dropdown forge-dropdown-table",
1103
- role: "list",
1104
- "aria-label": "Insert table",
1105
- children: [/* @__PURE__ */ c("div", {
1106
- ref: f,
1107
- className: "note-dimension-picker",
1108
- onMouseMove: p,
1109
- onMouseLeave: h,
1110
- onClick: g,
1111
- children: [
1112
- /* @__PURE__ */ c("div", { className: "note-dimension-picker-mousecatcher" }),
1113
- /* @__PURE__ */ c("div", {
1114
- className: "note-dimension-picker-highlighted",
1115
- style: {
1116
- width: _ + "%",
1117
- height: v + "%"
1118
- }
1119
- }),
1120
- /* @__PURE__ */ c("div", { className: "note-dimension-picker-unhighlighted" })
1121
- ]
1122
- }), /* @__PURE__ */ c("div", {
1123
- className: "note-dimension-display",
1124
- children: [
1125
- a,
1126
- " x ",
1127
- s
1128
- ]
1129
- })]
1130
- })]
1131
- });
1132
- }
1133
- //#endregion
1134
- //#region src/components/shared/toolbar/Table/Hooks/tableLogic.jsx
1135
- function N() {
1136
- let e = document.querySelector(".forge-editor__content");
1137
- if (e) {
1138
- e.focus();
1139
- let t = document.createRange(), n = window.getSelection();
1140
- if (n) {
1141
- let r = e.lastChild;
1142
- r ? (t.setStartAfter(r), t.collapse(!0)) : (t.selectNodeContents(e), t.collapse(!1)), n.removeAllRanges(), n.addRange(t);
1143
- }
1144
- }
1145
- }
1146
- function P(e) {
1147
- let t = window.getSelection();
1148
- if (!t || !t.rangeCount) {
1149
- N(), setTimeout(() => P(e), 50);
1150
- return;
1151
- }
1152
- let n = t.getRangeAt(0);
1153
- if (n.collapsed) {
1154
- let r = n.createContextualFragment(e);
1155
- n.insertNode(r);
1156
- let i = r.lastChild;
1157
- i ? (n.setStartAfter(i), n.collapse(!0)) : n.collapse(!1), t.removeAllRanges(), t.addRange(n);
1158
- } else document.execCommand("insertHTML", !1, e);
1159
- }
1160
- function F() {
1161
- return { insertTable: (e, t) => {
1162
- let n = "<table style=\"width:100%;border-collapse:collapse;border:1px solid #ddd;\">";
1163
- for (let r = 0; r < e; r++) {
1164
- n += "<tr>";
1165
- for (let e = 0; e < t; e++) n += "<td style=\"border:1px solid #ddd;padding:8px;\"><br></td>";
1166
- n += "</tr>";
1167
- }
1168
- n += "</table><br>", N(), P(n);
1169
- } };
1170
- }
1171
- //#endregion
1172
- //#region src/components/shared/toolbar/Table/Components/index.jsx
1173
- function I() {
1174
- return /* @__PURE__ */ c(M, { logic: F() });
1175
- }
1176
- //#endregion
1177
- //#region src/components/shared/toolbar/Insert/Components/InsertToolbar.jsx
1178
- function L({ logic: e }) {
1179
- let { insertLink: t, insertImage: n, insertVideo: r } = e;
1180
- return /* @__PURE__ */ c("div", {
1181
- className: "forge-toolbar-group forge-toolbar-insert",
1182
- children: [
1183
- /* @__PURE__ */ c("button", {
1184
- type: "button",
1185
- className: "forge-toolbar-button",
1186
- onClick: t,
1187
- "aria-label": "Link",
1188
- children: [/* @__PURE__ */ c("span", {
1189
- className: "forge-toolbar-icon",
1190
- children: "🔗"
1191
- }), /* @__PURE__ */ c("span", {
1192
- className: "forge-tooltip",
1193
- "data-i18n": "link",
1194
- children: "Link"
1195
- })]
1196
- }),
1197
- /* @__PURE__ */ c("button", {
1198
- type: "button",
1199
- className: "forge-toolbar-button",
1200
- onClick: n,
1201
- "aria-label": "Image",
1202
- children: [/* @__PURE__ */ c("span", {
1203
- className: "forge-toolbar-icon",
1204
- children: "🖼"
1205
- }), /* @__PURE__ */ c("span", {
1206
- className: "forge-tooltip",
1207
- "data-i18n": "image",
1208
- children: "Image"
1209
- })]
1210
- }),
1211
- /* @__PURE__ */ c("button", {
1212
- type: "button",
1213
- className: "forge-toolbar-button",
1214
- onClick: r,
1215
- "aria-label": "Video",
1216
- children: [/* @__PURE__ */ c("span", {
1217
- className: "forge-toolbar-icon",
1218
- children: "▶"
1219
- }), /* @__PURE__ */ c("span", {
1220
- className: "forge-tooltip",
1221
- "data-i18n": "video",
1222
- children: "Video"
1223
- })]
1224
- })
1225
- ]
1226
- });
1227
- }
1228
- //#endregion
1229
- //#region src/components/shared/Hooks/sweetAlert.jsx
1230
- function R({ title: e, inputs: t, confirmText: n, cancelText: r }) {
1231
- let i = t.map((e, t) => `<input id="${`swal-input-${t}`}" class="swal2-input" placeholder="${e.placeholder || ""}" value="${e.value || ""}">`).join("");
1232
- return a.fire({
1233
- title: e,
1234
- html: i,
1235
- focusConfirm: !1,
1236
- preConfirm: () => {
1237
- let e = t.map((e, t) => {
1238
- let n = `swal-input-${t}`, r = document.getElementById(n);
1239
- if (!r) return null;
1240
- let i = r.value;
1241
- return e.required && !i ? (a.showValidationMessage(e.requiredMessage || "This field is required"), !1) : i;
1242
- });
1243
- return !e.includes(!1) && e;
1244
- },
1245
- showCancelButton: !0,
1246
- confirmButtonText: n || "Confirm",
1247
- cancelButtonText: r || "Cancel"
1248
- });
1249
- }
1250
- //#endregion
1251
- //#region src/components/shared/toolbar/Insert/Hooks/insertLogic.jsx
1252
- function z() {
1253
- let e = window.getSelection();
1254
- return e && e.rangeCount > 0 ? e.getRangeAt(0).cloneRange() : null;
1255
- }
1256
- function B(e) {
1257
- if (!e) return;
1258
- let t = window.getSelection();
1259
- t && (t.removeAllRanges(), t.addRange(e));
1260
- }
1261
- function V() {
1262
- let e = document.querySelector(".forge-editor__content");
1263
- if (e) {
1264
- e.focus();
1265
- let t = document.createRange(), n = window.getSelection();
1266
- if (n) {
1267
- let r = e.lastChild;
1268
- r ? (t.setStartAfter(r), t.collapse(!0)) : (t.selectNodeContents(e), t.collapse(!1)), n.removeAllRanges(), n.addRange(t);
1269
- }
1270
- }
1271
- }
1272
- function H(e) {
1273
- let t = window.getSelection();
1274
- if (!t || !t.rangeCount) {
1275
- V(), setTimeout(() => H(e), 50);
1276
- return;
1277
- }
1278
- let n = t.getRangeAt(0);
1279
- if (n.collapsed) {
1280
- let r = n.createContextualFragment(e);
1281
- n.insertNode(r);
1282
- let i = r.lastChild;
1283
- i ? (n.setStartAfter(i), n.collapse(!0)) : n.collapse(!1), t.removeAllRanges(), t.addRange(n);
1284
- } else document.execCommand("insertHTML", !1, e);
1285
- }
1286
- function U() {
1287
- return {
1288
- insertLink: async () => {
1289
- let e = z(), t = await R({
1290
- title: "Insert Link",
1291
- inputs: [{
1292
- placeholder: "URL",
1293
- value: "https://",
1294
- required: !0,
1295
- requiredMessage: "URL is required"
1296
- }, { placeholder: "Link text (optional)" }],
1297
- confirmText: "Insert",
1298
- cancelText: "Cancel"
1299
- });
1300
- if (t.isConfirmed && t.value) {
1301
- B(e);
1302
- let [n, r] = t.value;
1303
- H(r ? `<a href="${n}" target="_blank">${r}</a>` : `<a href="${n}" target="_blank">${n}</a>`);
1304
- }
1305
- },
1306
- insertImage: async () => {
1307
- let e = z(), t = await R({
1308
- title: "Insert Image",
1309
- inputs: [{
1310
- placeholder: "Image URL",
1311
- value: "https://",
1312
- required: !0,
1313
- requiredMessage: "Image URL is required"
1314
- }, {
1315
- placeholder: "Alt text",
1316
- value: "Image"
1317
- }],
1318
- confirmText: "Insert",
1319
- cancelText: "Cancel"
1320
- });
1321
- if (t.isConfirmed && t.value) {
1322
- B(e);
1323
- let [n, r] = t.value;
1324
- H(`<img src="${n}" alt="${r}" style="max-width: 100%;">`);
1325
- }
1326
- },
1327
- insertVideo: async () => {
1328
- let e = z(), t = await R({
1329
- title: "Insert Video",
1330
- inputs: [{
1331
- placeholder: "Video URL (YouTube/Vimeo)",
1332
- value: "https://",
1333
- required: !0,
1334
- requiredMessage: "Video URL is required"
1335
- }],
1336
- confirmText: "Insert",
1337
- cancelText: "Cancel"
1338
- });
1339
- if (t.isConfirmed && t.value) {
1340
- B(e);
1341
- let [n] = t.value, r;
1342
- r = n.includes("youtube.com") || n.includes("youtu.be") ? `<iframe width="560" height="315" src="${n.replace("watch?v=", "embed/").replace("youtu.be/", "youtube.com/embed/")}" frameborder="0" allowfullscreen></iframe>` : `<video controls src="${n}" style="max-width: 100%;"></video>`, H(r);
1343
- }
1344
- }
1345
- };
1346
- }
1347
- //#endregion
1348
- //#region src/components/shared/toolbar/Insert/Components/index.jsx
1349
- function W() {
1350
- return /* @__PURE__ */ c(L, { logic: U() });
1351
- }
1352
- //#endregion
1353
- //#region src/components/shared/toolbar/View/Components/ViewToolbar.jsx
1354
- function G({ logic: e }) {
1355
- let { toggleFullscreen: t, toggleCodeView: n, showHelp: r } = e;
1356
- return /* @__PURE__ */ c("div", {
1357
- className: "forge-toolbar-group forge-toolbar-view",
1358
- children: [/* @__PURE__ */ c("button", {
1359
- type: "button",
1360
- className: "forge-toolbar-button",
1361
- onClick: t,
1362
- "aria-label": "Full Screen",
1363
- children: [/* @__PURE__ */ c("span", {
1364
- className: "forge-toolbar-icon",
1365
- children: "⛶"
1366
- }), /* @__PURE__ */ c("span", {
1367
- className: "forge-tooltip",
1368
- "data-i18n": "fullscreen",
1369
- children: "Full Screen"
1370
- })]
1371
- }), /* @__PURE__ */ c("button", {
1372
- type: "button",
1373
- className: "forge-toolbar-button",
1374
- onClick: n,
1375
- "aria-label": "Code View",
1376
- children: [/* @__PURE__ */ c("span", {
1377
- className: "forge-toolbar-icon",
1378
- children: "</>"
1379
- }), /* @__PURE__ */ c("span", {
1380
- className: "forge-tooltip",
1381
- "data-i18n": "codeview",
1382
- children: "Code View"
1383
- })]
1384
- })]
1385
- });
1386
- }
1387
- //#endregion
1388
- //#region src/components/shared/toolbar/View/Hooks/viewLogic.jsx
1389
- function te() {
1390
- return {
1391
- toggleFullscreen: () => {
1392
- let e = document.querySelector(".forge-editor");
1393
- e && (document.fullscreenElement ? document.exitFullscreen().catch(() => {}) : e.requestFullscreen().catch(() => {}));
1394
- },
1395
- toggleCodeView: () => {
1396
- let e = document.querySelector(".forge-editor__content");
1397
- e && (e.contentEditable === "true" ? (e.contentEditable = "false", e.textContent = e.innerHTML) : (e.contentEditable = "true", e.innerHTML = e.textContent), e.focus());
1398
- },
1399
- showHelp: () => {
1400
- let e = [
1401
- "Forge Editor - Keyboard Shortcuts:",
1402
- "",
1403
- "Bold: Ctrl+B",
1404
- "Underline: Ctrl+U",
1405
- "Link: Ctrl+K",
1406
- "Undo: Ctrl+Z",
1407
- "Redo: Ctrl+Y",
1408
- "",
1409
- "Visit: https://github.com/your-repo/forge-edit"
1410
- ].join("\n");
1411
- alert(e);
1412
- }
1413
- };
1414
- }
1415
- //#endregion
1416
- //#region src/components/shared/toolbar/View/Components/index.jsx
1417
- function K() {
1418
- return /* @__PURE__ */ c(G, { logic: te() });
1419
- }
1420
- //#endregion
1421
- //#region src/components/shared/toolbar/Index/index.jsx
1422
- function q() {
1423
- return /* @__PURE__ */ c("div", {
1424
- className: "forge-editor__toolbar",
1425
- role: "toolbar",
1426
- children: [
1427
- /* @__PURE__ */ c(u, {}),
1428
- /* @__PURE__ */ c(p, {}),
1429
- /* @__PURE__ */ c(v, {}),
1430
- /* @__PURE__ */ c(O, {}),
1431
- /* @__PURE__ */ c(A, {}),
1432
- /* @__PURE__ */ c(I, {}),
1433
- /* @__PURE__ */ c(W, {}),
1434
- /* @__PURE__ */ c(K, {})
1435
- ]
1436
- });
1437
- }
1438
- //#endregion
1439
- //#region src/components/shared/statusbar/Components/index.jsx
1440
- function J() {
1441
- return /* @__PURE__ */ c("div", {
1442
- className: "forge-statusbar",
1443
- role: "status",
1444
- children: /* @__PURE__ */ c("div", {
1445
- className: "forge-resizebar",
1446
- "aria-label": "resize",
1447
- children: [
1448
- /* @__PURE__ */ c("div", { className: "forge-icon-bar" }),
1449
- /* @__PURE__ */ c("div", { className: "forge-icon-bar" }),
1450
- /* @__PURE__ */ c("div", { className: "forge-icon-bar" })
1451
- ]
1452
- })
1453
- });
1454
- }
1455
- //#endregion
1456
- //#region src/components/shared/statusbar/Hooks/resize.js
1457
- var Y = 100;
1458
- function X(e, t, n = {}) {
1459
- let r = n.minHeight ?? Y, i = n.maxHeight ?? Infinity, a = 0, o = 0;
1460
- function s(e) {
1461
- let n = e.clientY - a, s = o + n;
1462
- s = Math.min(Math.max(s, r), i), t.style.height = `${s}px`;
1463
- }
1464
- function c() {
1465
- document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c), document.body.style.removeProperty("user-select"), document.body.style.removeProperty("cursor");
1466
- }
1467
- function l(e) {
1468
- e.preventDefault(), a = e.clientY, o = t.getBoundingClientRect().height, document.body.style.userSelect = "none", document.body.style.cursor = "s-resize", document.addEventListener("mousemove", s), document.addEventListener("mouseup", c);
1469
- }
1470
- return e.addEventListener("mousedown", l), function() {
1471
- e.removeEventListener("mousedown", l), document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c);
1472
- };
1473
- }
1474
- //#endregion
1475
- //#region src/components/shared/toolbar/Style/Hooks/styleLogic.jsx
1476
- function Z(e) {
1477
- let t = e.querySelector("[data-command='style']"), n = e.querySelector(".forge-dropdown-style");
1478
- if (!t || !n) {
1479
- console.warn("Style toolbar elements not found", e);
1480
- return;
1481
- }
1482
- m(t, n), n.querySelectorAll(".forge-dropdown-item").forEach((e) => {
1483
- e.addEventListener("click", (t) => {
1484
- t.preventDefault();
1485
- let r = e.dataset.value;
1486
- r && document.execCommand("formatBlock", !1, r), n.classList.remove("open");
1487
- });
1488
- });
1489
- }
1490
- //#endregion
1491
- //#region src/components/shared/i18n/index.js
1492
- var Q = {
1493
- en: {
1494
- style: "Style",
1495
- normal: "Normal",
1496
- blockquote: "Blockquote",
1497
- code: "Code",
1498
- header1: "Header 1",
1499
- header2: "Header 2",
1500
- header3: "Header 3",
1501
- header4: "Header 4",
1502
- header5: "Header 5",
1503
- header6: "Header 6",
1504
- bold: "Bold",
1505
- underline: "Underline",
1506
- removeFormat: "Remove Font Style",
1507
- fontName: "Font Family",
1508
- recentColor: "Recent Color",
1509
- moreColor: "More Color",
1510
- recentBackColor: "Recent Background Color",
1511
- moreBackColor: "More Background Colors",
1512
- insertUnorderedList: "Unordered List",
1513
- insertOrderedList: "Ordered List",
1514
- paragraph: "Paragraph",
1515
- justifyLeft: "Align Left",
1516
- justifyCenter: "Align Center",
1517
- justifyRight: "Align Right",
1518
- justifyFull: "Justify",
1519
- outdent: "Outdent",
1520
- indent: "Indent",
1521
- table: "Table",
1522
- link: "Link",
1523
- picture: "Picture",
1524
- video: "Video",
1525
- fullscreen: "Full Screen",
1526
- codeview: "Code View",
1527
- help: "Help"
1528
- },
1529
- ar: {
1530
- style: "نمط",
1531
- normal: "عادي",
1532
- blockquote: "اقتباس",
1533
- code: "كود",
1534
- header1: "عنوان 1",
1535
- header2: "عنوان 2",
1536
- header3: "عنوان 3",
1537
- header4: "عنوان 4",
1538
- header5: "عنوان 5",
1539
- header6: "عنوان 6",
1540
- bold: "عريض",
1541
- underline: "تسطير",
1542
- removeFormat: "إزالة تنسيق الخط",
1543
- fontName: "نوع الخط",
1544
- recentColor: "آخر لون مستخدم",
1545
- moreColor: "المزيد من الألوان",
1546
- recentBackColor: "آخر لون خلفية",
1547
- moreBackColor: "المزيد من ألوان الخلفية",
1548
- insertUnorderedList: "قائمة نقطية",
1549
- insertOrderedList: "قائمة مرقمة",
1550
- paragraph: "فقرة",
1551
- justifyLeft: "محاذاة لليسار",
1552
- justifyCenter: "محاذاة للوسط",
1553
- justifyRight: "محاذاة لليمين",
1554
- justifyFull: "ضبط",
1555
- outdent: "تقليل المسافة البادئة",
1556
- indent: "زيادة المسافة البادئة",
1557
- table: "جدول",
1558
- link: "رابط",
1559
- picture: "صورة",
1560
- video: "فيديو",
1561
- fullscreen: "ملء الشاشة",
1562
- codeview: "عرض الكود",
1563
- help: "مساعدة"
1564
- }
1565
- }, $ = "en";
1566
- function ne(e, t) {
1567
- return (Q[e] || Q[$])[t] || Q[$][t] || t;
1568
- }
1569
- //#endregion
1570
- //#region src/components/shared/i18n/apply.js
1571
- function re(e, t) {
1572
- e.querySelectorAll("[data-i18n]").forEach((e) => {
1573
- e.textContent = ne(t, e.getAttribute("data-i18n"));
1574
- });
1575
- }
1576
- //#endregion
1577
- //#region src/components/shared/toolbar/Style/Utils/ensureParagraph.jsx
1578
- function ie(e) {
1579
- if (e && !(e.children.length > 0 || e.textContent.trim().length > 0)) {
1580
- let t = document.createElement("p");
1581
- t.innerHTML = "<br>", e.appendChild(t);
1582
- }
1583
- }
1584
- //#endregion
1585
- //#region src/components/shared/toolbar/ImagePopover/Components/ImagePopover.jsx
1586
- function ae({ target: e, onClose: t, onResize: n, onFloat: i, onRemove: a }) {
1587
- let o = r(null);
1588
- if (!e) return null;
1589
- let s = e.getBoundingClientRect();
1590
- return /* @__PURE__ */ c("div", {
1591
- ref: o,
1592
- className: "note-popover bottom note-image-popover",
1593
- style: {
1594
- display: "block",
1595
- left: s.left + s.width / 2 - 100 + "px",
1596
- top: s.bottom + 10 + "px",
1597
- position: "fixed",
1598
- zIndex: 9999
1599
- },
1600
- children: [/* @__PURE__ */ c("div", { className: "note-popover-arrow" }), /* @__PURE__ */ c("div", {
1601
- className: "popover-content note-children-container",
1602
- children: [
1603
- /* @__PURE__ */ c("div", {
1604
- className: "note-btn-group note-resize",
1605
- children: [
1606
- /* @__PURE__ */ c("button", {
1607
- type: "button",
1608
- className: "note-btn",
1609
- tabIndex: "-1",
1610
- "aria-label": "Resize full",
1611
- onClick: () => n(e, 1),
1612
- children: /* @__PURE__ */ c("span", {
1613
- className: "note-fontsize-10",
1614
- children: "100%"
1615
- })
1616
- }),
1617
- /* @__PURE__ */ c("button", {
1618
- type: "button",
1619
- className: "note-btn",
1620
- tabIndex: "-1",
1621
- "aria-label": "Resize half",
1622
- onClick: () => n(e, .5),
1623
- children: /* @__PURE__ */ c("span", {
1624
- className: "note-fontsize-10",
1625
- children: "50%"
1626
- })
1627
- }),
1628
- /* @__PURE__ */ c("button", {
1629
- type: "button",
1630
- className: "note-btn",
1631
- tabIndex: "-1",
1632
- "aria-label": "Resize quarter",
1633
- onClick: () => n(e, .25),
1634
- children: /* @__PURE__ */ c("span", {
1635
- className: "note-fontsize-10",
1636
- children: "25%"
1637
- })
1638
- }),
1639
- /* @__PURE__ */ c("button", {
1640
- type: "button",
1641
- className: "note-btn",
1642
- tabIndex: "-1",
1643
- "aria-label": "Original size",
1644
- onClick: () => n(e, "original"),
1645
- children: /* @__PURE__ */ c("i", {
1646
- className: "note-icon-rollback",
1647
- children: "↺"
1648
- })
1649
- })
1650
- ]
1651
- }),
1652
- /* @__PURE__ */ c("div", {
1653
- className: "note-btn-group note-float",
1654
- children: [
1655
- /* @__PURE__ */ c("button", {
1656
- type: "button",
1657
- className: "note-btn",
1658
- tabIndex: "-1",
1659
- "aria-label": "Float Left",
1660
- onClick: () => i(e, "left"),
1661
- children: /* @__PURE__ */ c("i", {
1662
- className: "note-icon-float-left",
1663
- children: "◀"
1664
- })
1665
- }),
1666
- /* @__PURE__ */ c("button", {
1667
- type: "button",
1668
- className: "note-btn",
1669
- tabIndex: "-1",
1670
- "aria-label": "Float Right",
1671
- onClick: () => i(e, "right"),
1672
- children: /* @__PURE__ */ c("i", {
1673
- className: "note-icon-float-right",
1674
- children: "▶"
1675
- })
1676
- }),
1677
- /* @__PURE__ */ c("button", {
1678
- type: "button",
1679
- className: "note-btn",
1680
- tabIndex: "-1",
1681
- "aria-label": "Remove float",
1682
- onClick: () => i(e, "none"),
1683
- children: /* @__PURE__ */ c("i", {
1684
- className: "note-icon-rollback",
1685
- children: "↺"
1686
- })
1687
- })
1688
- ]
1689
- }),
1690
- /* @__PURE__ */ c("div", {
1691
- className: "note-btn-group note-remove",
1692
- children: /* @__PURE__ */ c("button", {
1693
- type: "button",
1694
- className: "note-btn",
1695
- tabIndex: "-1",
1696
- "aria-label": "Remove Image",
1697
- onClick: () => a(e),
1698
- children: /* @__PURE__ */ c("i", {
1699
- className: "note-icon-trash",
1700
- children: "🗑"
1701
- })
1702
- })
1703
- })
1704
- ]
1705
- })]
1706
- });
1707
- }
1708
- //#endregion
1709
- //#region src/components/shared/toolbar/ImagePopover/Hooks/useImagePopover.jsx
1710
- function oe() {
1711
- let [e, t] = i(null), [r, a] = i(!1);
1712
- return n(() => {
1713
- let e = (e) => {
1714
- let n = e.target.closest("img");
1715
- n ? (t(n), a(!0)) : r && (a(!1), t(null));
1716
- }, n = (e) => {
1717
- e.key === "Escape" && r && (a(!1), t(null));
1718
- };
1719
- return document.addEventListener("click", e), document.addEventListener("keydown", n), () => {
1720
- document.removeEventListener("click", e), document.removeEventListener("keydown", n);
1721
- };
1722
- }, [r]), {
1723
- target: r ? e : null,
1724
- onClose: () => {
1725
- a(!1), t(null);
1726
- },
1727
- onResize: (e, n) => {
1728
- if (n === "original") e.style.width = "", e.style.height = "", e.removeAttribute("width"), e.removeAttribute("height");
1729
- else {
1730
- let t = e.naturalWidth || e.width, r = e.naturalHeight || e.height;
1731
- e.style.width = t * n + "px", e.style.height = r * n + "px";
1732
- }
1733
- a(!1), t(null);
1734
- },
1735
- onFloat: (e, n) => {
1736
- n === "none" ? (e.style.float = "", e.style.margin = "") : (e.style.float = n, e.style.margin = n === "left" ? "0 10px 5px 0" : "0 0 5px 10px"), a(!1), t(null);
1737
- },
1738
- onRemove: (e) => {
1739
- e.parentElement.removeChild(e), a(!1), t(null);
1740
- }
1741
- };
1742
- }
1743
- //#endregion
1744
- //#region src/components/shared/toolbar/ImagePopover/Components/index.jsx
1745
- function se() {
1746
- return /* @__PURE__ */ c(ae, { ...oe() });
1747
- }
1748
- //#endregion
1749
- //#region src/components/light/index.jsx
1750
- function ce(e) {
1751
- return {
1752
- getHTML() {
1753
- return e.innerHTML;
1754
- },
1755
- setHTML(t) {
1756
- e.innerHTML = t;
1757
- },
1758
- getText() {
1759
- return e.textContent;
1760
- },
1761
- getSelection() {
1762
- let e = window.getSelection();
1763
- return e ? e.toString() : "";
1764
- }
1765
- };
1766
- }
1767
- function le(e) {
1768
- let n = e.lang || "en", r = /* @__PURE__ */ c("div", {
1769
- className: "forge-editor forge-editor--light",
1770
- lang: n,
1771
- dir: e.dir || "ltr",
1772
- children: [
1773
- /* @__PURE__ */ c(q, {}),
1774
- /* @__PURE__ */ c("div", {
1775
- className: "forge-editor__content",
1776
- contentEditable: "true",
1777
- "data-placeholder": e.placeholder || ""
1778
- }),
1779
- /* @__PURE__ */ c(J, {}),
1780
- /* @__PURE__ */ c(se, {})
1781
- ]
1782
- }), i = document.createElement("div");
1783
- t(r, i);
1784
- let a = i.firstElementChild, o = a.querySelector(".forge-editor__content");
1785
- return ie(o), Z(a.querySelector(".forge-toolbar-style")), re(a.querySelector(".forge-editor__toolbar"), n), X(a.querySelector(".forge-statusbar"), a, { minHeight: 100 }), {
1786
- element: a,
1787
- ...ce(o)
1788
- };
1789
- }
1790
- //#endregion
1791
- //#region src/main/index.jsx
1792
- function ue(e) {
1793
- let t = o(e);
1794
- if (t.type === "light") {
1795
- let { element: n, getHTML: r, setHTML: i, getText: a, getSelection: o } = le(t);
1796
- return e.innerHTML = "", e.appendChild(n), n.style.width = t.width, n.style.height = t.height, {
1797
- element: n,
1798
- getHTML: r,
1799
- setHTML: i,
1800
- getText: a,
1801
- getSelection: o
1802
- };
1803
- }
1804
- return null;
1805
- }
1806
- //#endregion
1807
- export { ue as default };