@siladev/qalam 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { useRef as O, useCallback as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as r, jsxs as g, Fragment as A } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as O, useCallback as G, useEffect as J, useState as F, useLayoutEffect as K } from "react";
|
|
3
|
+
const v = "ـ", U = new Set("سشصض"), V = new Set("ةهد"), z = new Set("طلكگ"), X = new Set("عقف"), M = new Set(
|
|
4
4
|
"بتثجحخسشصضطظعغفقكلمنهيئپچژگ"
|
|
5
5
|
);
|
|
6
6
|
new Set("ادذرزوأإآؤ");
|
|
7
|
-
const
|
|
7
|
+
const Y = new Set("اأإآ");
|
|
8
8
|
function B(e) {
|
|
9
9
|
const t = e.charCodeAt(0);
|
|
10
10
|
return t >= 1569 && t <= 1610 || t >= 1646 && t <= 1747 || t >= 64336 && t <= 65023;
|
|
@@ -21,7 +21,7 @@ function D(e, t) {
|
|
|
21
21
|
return B(e[a]);
|
|
22
22
|
return !1;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function Z(e, t) {
|
|
25
25
|
for (let n = t + 1; n < e.length; n++)
|
|
26
26
|
if (!S(e[n])) {
|
|
27
27
|
if (B(e[n])) return !1;
|
|
@@ -29,42 +29,42 @@ function Y(e, t) {
|
|
|
29
29
|
}
|
|
30
30
|
return !0;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function ee(e, t) {
|
|
33
33
|
for (let n = t - 1; n >= 0; n--)
|
|
34
34
|
if (!S(e[n]))
|
|
35
35
|
return M.has(e[n]);
|
|
36
36
|
return !1;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function H(e, t) {
|
|
39
39
|
if (e[t] !== "ل") return !1;
|
|
40
40
|
for (let n = t + 1; n < e.length; n++)
|
|
41
41
|
if (!S(e[n]))
|
|
42
|
-
return
|
|
42
|
+
return Y.has(e[n]);
|
|
43
43
|
return !1;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function te(e) {
|
|
46
46
|
const t = [];
|
|
47
47
|
for (let n = 0; n < e.length; n++) {
|
|
48
48
|
const a = e[n];
|
|
49
|
-
if (a.includes(
|
|
49
|
+
if (a.includes(v)) continue;
|
|
50
50
|
let s = null;
|
|
51
51
|
for (let i = 0; i < a.length; i++) {
|
|
52
52
|
if (S(a[i])) continue;
|
|
53
53
|
const c = a[i];
|
|
54
|
-
if (
|
|
54
|
+
if (U.has(c) && D(a, i) && !H(a, i)) {
|
|
55
55
|
const l = { wordIndex: n, charIndex: i + 1, priority: 1 };
|
|
56
56
|
(!s || l.priority < s.priority) && (s = l);
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
|
-
if (
|
|
59
|
+
if (Z(a, i) && ee(a, i)) {
|
|
60
60
|
let l = 0;
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
(!s ||
|
|
61
|
+
if (V.has(c) ? l = 2 : z.has(c) ? l = 3 : X.has(c) && (l = 4), l > 0) {
|
|
62
|
+
const d = { wordIndex: n, charIndex: i, priority: l };
|
|
63
|
+
(!s || d.priority < s.priority) && (s = d);
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
if (M.has(c) && D(a, i) && !
|
|
67
|
+
if (M.has(c) && D(a, i) && !H(a, i)) {
|
|
68
68
|
const l = { wordIndex: n, charIndex: i + 1, priority: 5 };
|
|
69
69
|
(!s || l.priority < s.priority) && (s = l);
|
|
70
70
|
}
|
|
@@ -73,42 +73,52 @@ function ee(e) {
|
|
|
73
73
|
}
|
|
74
74
|
return t;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function P(e, t) {
|
|
77
77
|
for (; t < e.length && S(e[t]); ) t++;
|
|
78
78
|
return t;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
const a =
|
|
82
|
-
return e.slice(0, a) +
|
|
80
|
+
function j(e, t, n = 1) {
|
|
81
|
+
const a = P(e, t);
|
|
82
|
+
return e.slice(0, a) + v.repeat(n) + e.slice(a);
|
|
83
83
|
}
|
|
84
84
|
function ne(e, t, n, a = 50) {
|
|
85
85
|
let s = e, i = t(s);
|
|
86
86
|
if (i >= n) return s;
|
|
87
87
|
for (let c = 0; c < a; c++) {
|
|
88
|
-
const l = s.split(" "),
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
for (const { word:
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
88
|
+
const l = s.split(" "), d = te(l);
|
|
89
|
+
if (d.length === 0) {
|
|
90
|
+
const m = l.map((o, h) => ({ word: o, index: h })).filter(({ word: o }) => o.includes(v));
|
|
91
|
+
if (m.length === 0) break;
|
|
92
|
+
for (const { word: o, index: h } of m) {
|
|
93
|
+
const f = o.indexOf(v), k = o.split(v).length - 1;
|
|
94
|
+
if (k === 2) {
|
|
95
|
+
const b = P(o, f + k);
|
|
96
|
+
if (b < o.length && o[b] === "ا") {
|
|
97
|
+
const q = j(o, f, 2), y = [...l];
|
|
98
|
+
y[h] = q;
|
|
99
|
+
const R = t(y.join(" "));
|
|
100
|
+
R <= n && (l[h] = q, s = y.join(" "), i = R);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (l[h] = j(o, f, 1), s = l.join(" "), i = t(s), i >= n) return s;
|
|
95
105
|
}
|
|
96
106
|
continue;
|
|
97
107
|
}
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
if (l[
|
|
108
|
+
d.sort((m, o) => m.priority - o.priority);
|
|
109
|
+
const p = d[0];
|
|
110
|
+
if (l[p.wordIndex] = j(l[p.wordIndex], p.charIndex), s = l.join(" "), i = t(s), i >= n) return s;
|
|
101
111
|
}
|
|
102
112
|
return s;
|
|
103
113
|
}
|
|
104
|
-
function
|
|
114
|
+
function C(e) {
|
|
105
115
|
if (e === 2) return "(مرتان)";
|
|
106
116
|
const t = e.toString().replace(/\d/g, (n) => "٠١٢٣٤٥٦٧٨٩"[parseInt(n)]);
|
|
107
117
|
return e > 10 ? `(${t} مرة)` : `(${t} مرات)`;
|
|
108
118
|
}
|
|
109
|
-
function
|
|
119
|
+
function Q(e, t, n) {
|
|
110
120
|
if (n >= t.length) return /* @__PURE__ */ r(A, { children: e });
|
|
111
|
-
const a = t[n], s =
|
|
121
|
+
const a = t[n], s = Q(e, t, n + 1);
|
|
112
122
|
switch (a.type) {
|
|
113
123
|
case "bold":
|
|
114
124
|
return /* @__PURE__ */ r("strong", { children: s });
|
|
@@ -117,9 +127,9 @@ function P(e, t, n) {
|
|
|
117
127
|
case "link":
|
|
118
128
|
return /* @__PURE__ */ r("a", { href: a.attrs.href, target: a.attrs.target ?? "_blank", rel: "noopener noreferrer", children: s });
|
|
119
129
|
case "repeat":
|
|
120
|
-
return /* @__PURE__ */
|
|
130
|
+
return /* @__PURE__ */ g("span", { className: "qalam-render-inline-repeat", children: [
|
|
121
131
|
s,
|
|
122
|
-
/* @__PURE__ */ r("span", { className: "qalam-render-inline-repeat-badge", children:
|
|
132
|
+
/* @__PURE__ */ r("span", { className: "qalam-render-inline-repeat-badge", children: C(a.attrs.count) })
|
|
123
133
|
] });
|
|
124
134
|
case "propheticSpeech":
|
|
125
135
|
return /* @__PURE__ */ r("span", { className: "qalam-render-prophetic-speech", children: s });
|
|
@@ -128,26 +138,26 @@ function P(e, t, n) {
|
|
|
128
138
|
}
|
|
129
139
|
}
|
|
130
140
|
function ae({ node: e }) {
|
|
131
|
-
return e.marks?.length ?
|
|
141
|
+
return e.marks?.length ? Q(e.text, e.marks, 0) : /* @__PURE__ */ r(A, { children: e.text });
|
|
132
142
|
}
|
|
133
143
|
function re({ seg: e, index: t }) {
|
|
134
144
|
const n = /* @__PURE__ */ r("span", { className: "qalam-render-verse", children: e.textHafsSmart });
|
|
135
|
-
return e.repeat > 1 ? /* @__PURE__ */
|
|
145
|
+
return e.repeat > 1 ? /* @__PURE__ */ g(A, { children: [
|
|
136
146
|
/* @__PURE__ */ r("span", { className: "qalam-render-repeat", children: n }),
|
|
137
|
-
/* @__PURE__ */ r("span", { className: "qalam-render-repeat-badge", children:
|
|
147
|
+
/* @__PURE__ */ r("span", { className: "qalam-render-repeat-badge", children: C(e.repeat) })
|
|
138
148
|
] }) : n;
|
|
139
149
|
}
|
|
140
150
|
function se({ node: e }) {
|
|
141
151
|
const { resolved: t } = e, n = t.segments.map((s) => s.textCopy).join(" "), a = t.basmalah ? `بِسْمِ اللَّهِ الرَّحْمَـٰنِ الرَّحِيمِ ${n}` : n;
|
|
142
|
-
return /* @__PURE__ */
|
|
152
|
+
return /* @__PURE__ */ g("span", { className: "qalam-render-quran", "data-copy": a, "data-citation": t.citation, children: [
|
|
143
153
|
/* @__PURE__ */ r("span", { className: "qalam-render-seo", "aria-hidden": "false", children: a }),
|
|
144
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ g("span", { "aria-hidden": "true", children: [
|
|
145
155
|
/* @__PURE__ */ r("span", { className: "qalam-render-bracket", children: "﴿" }),
|
|
146
|
-
t.basmalah && /* @__PURE__ */
|
|
156
|
+
t.basmalah && /* @__PURE__ */ g(A, { children: [
|
|
147
157
|
/* @__PURE__ */ r("span", { className: "qalam-render-basmalah", children: "" }),
|
|
148
158
|
" "
|
|
149
159
|
] }),
|
|
150
|
-
t.segments.map((s, i) => /* @__PURE__ */
|
|
160
|
+
t.segments.map((s, i) => /* @__PURE__ */ g("span", { children: [
|
|
151
161
|
i > 0 && " ",
|
|
152
162
|
/* @__PURE__ */ r(re, { seg: s, index: i })
|
|
153
163
|
] }, i)),
|
|
@@ -172,13 +182,13 @@ function ie({ node: e }) {
|
|
|
172
182
|
}
|
|
173
183
|
const i = [];
|
|
174
184
|
for (let c = 0; c < n.length; c++)
|
|
175
|
-
a[c] && (c === 0 || !a[c - 1]) && i.push(/* @__PURE__ */ r("span", { className: "qalam-render-prophetic-quote", children: "”" }, `q-open-${c}`)), i.push(/* @__PURE__ */ r(
|
|
176
|
-
return /* @__PURE__ */
|
|
185
|
+
a[c] && (c === 0 || !a[c - 1]) && i.push(/* @__PURE__ */ r("span", { className: "qalam-render-prophetic-quote", children: "”" }, `q-open-${c}`)), i.push(/* @__PURE__ */ r(_, { node: n[c] }, c)), a[c] && (c === n.length - 1 || !a[c + 1]) && i.push(/* @__PURE__ */ r("span", { className: "qalam-render-prophetic-quote", children: "“" }, `q-close-${c}`));
|
|
186
|
+
return /* @__PURE__ */ g("span", { className: "qalam-render-hadith", children: [
|
|
177
187
|
/* @__PURE__ */ r("span", { className: "qalam-render-hadith-bracket", children: "«" }),
|
|
178
188
|
i,
|
|
179
189
|
/* @__PURE__ */ r("span", { className: "qalam-render-hadith-bracket", children: "»" }),
|
|
180
190
|
t.citation && /* @__PURE__ */ r("span", { className: "qalam-render-hadith-citation", children: `[${t.citation}]` }),
|
|
181
|
-
t.grade && /* @__PURE__ */
|
|
191
|
+
t.grade && /* @__PURE__ */ g("span", { className: "qalam-render-hadith-grade", children: [
|
|
182
192
|
"(",
|
|
183
193
|
t.grade,
|
|
184
194
|
")"
|
|
@@ -186,15 +196,15 @@ function ie({ node: e }) {
|
|
|
186
196
|
] });
|
|
187
197
|
}
|
|
188
198
|
function le({ node: e }) {
|
|
189
|
-
const
|
|
190
|
-
return /* @__PURE__ */
|
|
199
|
+
const t = e.attrs?.citation;
|
|
200
|
+
return /* @__PURE__ */ g("span", { className: "qalam-render-quote", children: [
|
|
191
201
|
/* @__PURE__ */ r("span", { className: "qalam-render-quote-bracket", children: "”" }),
|
|
192
|
-
e.content?.map((n, a) => /* @__PURE__ */ r(
|
|
202
|
+
e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)),
|
|
193
203
|
/* @__PURE__ */ r("span", { className: "qalam-render-quote-bracket", children: "“" }),
|
|
194
204
|
t && /* @__PURE__ */ r("cite", { className: "qalam-render-quote-citation", children: ` [${t}]` })
|
|
195
205
|
] });
|
|
196
206
|
}
|
|
197
|
-
function
|
|
207
|
+
function _({ node: e }) {
|
|
198
208
|
switch (e.type) {
|
|
199
209
|
case "text":
|
|
200
210
|
return /* @__PURE__ */ r(ae, { node: e });
|
|
@@ -212,84 +222,84 @@ function C({ node: e }) {
|
|
|
212
222
|
}
|
|
213
223
|
function oe({ node: e }) {
|
|
214
224
|
const t = O(null), [n, a] = F(null), [s, i] = F(!1), [c, l] = F(void 0);
|
|
215
|
-
return
|
|
216
|
-
const
|
|
217
|
-
if (!
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
let
|
|
222
|
-
for (const
|
|
223
|
-
!
|
|
224
|
-
const
|
|
225
|
-
let
|
|
226
|
-
const
|
|
227
|
-
for (let
|
|
228
|
-
const
|
|
229
|
-
if (!
|
|
230
|
-
for (let
|
|
231
|
-
const
|
|
232
|
-
|
|
225
|
+
return K(() => {
|
|
226
|
+
const d = t.current;
|
|
227
|
+
if (!d) return;
|
|
228
|
+
const p = document.createElement("span");
|
|
229
|
+
p.className = "qalam-render-poem__shatr", p.style.position = "absolute", p.style.visibility = "hidden", p.style.whiteSpace = "nowrap", p.style.width = "auto", d.appendChild(p);
|
|
230
|
+
const m = (u) => (p.textContent = u, p.scrollWidth), o = d.parentElement?.clientWidth ?? d.clientWidth, h = 32;
|
|
231
|
+
let f = 1;
|
|
232
|
+
for (const u of e.content)
|
|
233
|
+
!u.attrs.separator && u.attrs.parts.length > f && (f = u.attrs.parts.length);
|
|
234
|
+
const k = o / f, b = k - h;
|
|
235
|
+
let q = !1, y = 0;
|
|
236
|
+
const R = [];
|
|
237
|
+
for (let u = 0; u < e.content.length; u++) {
|
|
238
|
+
const x = e.content[u];
|
|
239
|
+
if (!x.attrs.separator)
|
|
240
|
+
for (let w = 0; w < x.attrs.parts.length; w++) {
|
|
241
|
+
const W = x.attrs.parts[w], $ = W ? m(W) : 0;
|
|
242
|
+
R.push({ key: `${u}-${w}`, text: W, naturalWidth: $ }), W && ($ > y && (y = $), x.attrs.parts.length > 1 && $ > b && (q = !0));
|
|
233
243
|
}
|
|
234
244
|
}
|
|
235
|
-
i(
|
|
236
|
-
const
|
|
237
|
-
l(
|
|
238
|
-
const
|
|
239
|
-
for (const { key:
|
|
240
|
-
if (!
|
|
241
|
-
|
|
245
|
+
i(q);
|
|
246
|
+
const N = y * 1.3 + h, I = Math.min(N, k), L = q ? y : I - h;
|
|
247
|
+
l(q ? o : Math.min(I * f, o));
|
|
248
|
+
const E = /* @__PURE__ */ new Map();
|
|
249
|
+
for (const { key: u, text: x, naturalWidth: w } of R) {
|
|
250
|
+
if (!x) {
|
|
251
|
+
E.set(u, x);
|
|
242
252
|
continue;
|
|
243
253
|
}
|
|
244
|
-
|
|
254
|
+
w >= L ? E.set(u, x) : E.set(u, ne(x, m, L));
|
|
245
255
|
}
|
|
246
|
-
|
|
247
|
-
}, [e]), /* @__PURE__ */
|
|
256
|
+
d.removeChild(p), a(E);
|
|
257
|
+
}, [e]), /* @__PURE__ */ g("div", { ref: t, className: `qalam-render-poem${s ? " qalam-render-poem--stacked" : ""}`, style: c ? { maxWidth: c } : void 0, children: [
|
|
248
258
|
e.content.map(
|
|
249
|
-
(
|
|
250
|
-
|
|
251
|
-
const
|
|
259
|
+
(d, p) => d.attrs.separator ? /* @__PURE__ */ r("div", { className: "qalam-render-poem__separator", children: "* * *" }, p) : /* @__PURE__ */ g("div", { className: "qalam-render-poem__bayt", children: [
|
|
260
|
+
d.attrs.parts.map((m, o) => {
|
|
261
|
+
const h = `${p}-${o}`, f = n?.get(h) ?? m;
|
|
252
262
|
return /* @__PURE__ */ r(
|
|
253
263
|
"span",
|
|
254
264
|
{
|
|
255
265
|
className: "qalam-render-poem__shatr",
|
|
256
|
-
"data-shatr-key":
|
|
257
|
-
"data-shatr-text":
|
|
258
|
-
children:
|
|
266
|
+
"data-shatr-key": h,
|
|
267
|
+
"data-shatr-text": m,
|
|
268
|
+
children: f
|
|
259
269
|
},
|
|
260
|
-
|
|
270
|
+
o
|
|
261
271
|
);
|
|
262
272
|
}),
|
|
263
|
-
(
|
|
264
|
-
] },
|
|
273
|
+
(d.attrs.repeat ?? 1) > 1 && /* @__PURE__ */ r("span", { className: "qalam-render-poem__repeat-badge", children: C(d.attrs.repeat) })
|
|
274
|
+
] }, p)
|
|
265
275
|
),
|
|
266
276
|
e.attrs?.citation && /* @__PURE__ */ r("cite", { className: "qalam-render-poem-citation", children: `[${e.attrs.citation}]` })
|
|
267
277
|
] });
|
|
268
278
|
}
|
|
269
|
-
function
|
|
279
|
+
function T({ node: e }) {
|
|
270
280
|
switch (e.type) {
|
|
271
281
|
case "paragraph": {
|
|
272
282
|
const t = e.attrs?.repeat ?? 1;
|
|
273
|
-
return t > 1 ? /* @__PURE__ */
|
|
274
|
-
e.content?.map((n, a) => /* @__PURE__ */ r(
|
|
275
|
-
/* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-ghost", children:
|
|
276
|
-
/* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children:
|
|
277
|
-
] }) : /* @__PURE__ */ r("p", { children: e.content?.map((n, a) => /* @__PURE__ */ r(
|
|
283
|
+
return t > 1 ? /* @__PURE__ */ g("p", { className: "qalam-render-block-repeat", children: [
|
|
284
|
+
e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)),
|
|
285
|
+
/* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-ghost", children: C(t) }),
|
|
286
|
+
/* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children: C(t) })
|
|
287
|
+
] }) : /* @__PURE__ */ r("p", { children: e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)) });
|
|
278
288
|
}
|
|
279
289
|
case "heading": {
|
|
280
290
|
const t = `h${e.attrs.level}`;
|
|
281
|
-
return /* @__PURE__ */ r(t, { children: e.content?.map((n, a) => /* @__PURE__ */ r(
|
|
291
|
+
return /* @__PURE__ */ r(t, { children: e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)) });
|
|
282
292
|
}
|
|
283
293
|
case "bulletList":
|
|
284
|
-
return /* @__PURE__ */ r("ul", { children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(
|
|
294
|
+
return /* @__PURE__ */ r("ul", { children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(T, { node: a }, s)) }, n)) });
|
|
285
295
|
case "orderedList":
|
|
286
|
-
return /* @__PURE__ */ r("ol", { ...e.attrs?.listType === "abjad" ? { "data-list-type": "abjad", style: { "--qalam-ol-style": "abjad" } } : {}, children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(
|
|
296
|
+
return /* @__PURE__ */ r("ol", { ...e.attrs?.listType === "abjad" ? { "data-list-type": "abjad", style: { "--qalam-ol-style": "abjad" } } : {}, children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(T, { node: a }, s)) }, n)) });
|
|
287
297
|
case "blockquote": {
|
|
288
298
|
const t = e.attrs?.repeat ?? 1, n = e.attrs?.citation;
|
|
289
|
-
return /* @__PURE__ */
|
|
290
|
-
e.content.map((a, s) => /* @__PURE__ */ r(
|
|
299
|
+
return /* @__PURE__ */ g("blockquote", { className: t > 1 ? "qalam-render-block-repeat" : void 0, ...n ? { "data-citation": n } : {}, children: [
|
|
300
|
+
e.content.map((a, s) => /* @__PURE__ */ r(T, { node: a }, s)),
|
|
291
301
|
n && /* @__PURE__ */ r("cite", { className: "qalam-render-blockquote-citation", children: `[${n}]` }),
|
|
292
|
-
t > 1 && /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children:
|
|
302
|
+
t > 1 && /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children: C(t) })
|
|
293
303
|
] });
|
|
294
304
|
}
|
|
295
305
|
case "poem":
|
|
@@ -299,41 +309,41 @@ function W({ node: e }) {
|
|
|
299
309
|
}
|
|
300
310
|
}
|
|
301
311
|
function he({ doc: e, className: t, dir: n = "rtl" }) {
|
|
302
|
-
const a = O(null), s =
|
|
312
|
+
const a = O(null), s = G((i) => {
|
|
303
313
|
const c = window.getSelection();
|
|
304
314
|
if (!c || c.isCollapsed) return;
|
|
305
315
|
const l = a.current;
|
|
306
316
|
if (!l) return;
|
|
307
|
-
const
|
|
308
|
-
let
|
|
309
|
-
for (const
|
|
310
|
-
if (
|
|
311
|
-
|
|
317
|
+
const d = c.getRangeAt(0), p = l.querySelectorAll(".qalam-render-quran");
|
|
318
|
+
let m = !1;
|
|
319
|
+
for (const N of p)
|
|
320
|
+
if (d.intersectsNode(N)) {
|
|
321
|
+
m = !0;
|
|
312
322
|
break;
|
|
313
323
|
}
|
|
314
|
-
if (!
|
|
324
|
+
if (!m) return;
|
|
315
325
|
i.preventDefault();
|
|
316
|
-
const
|
|
317
|
-
for (const
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
let
|
|
321
|
-
for (;
|
|
322
|
-
|
|
323
|
-
for (const
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
+
const o = d.cloneRange();
|
|
327
|
+
for (const N of p)
|
|
328
|
+
d.intersectsNode(N) && (N.contains(d.startContainer) && o.setStartBefore(N), N.contains(d.endContainer) && o.setEndAfter(N));
|
|
329
|
+
const h = o.cloneContents(), f = document.createTreeWalker(h, NodeFilter.SHOW_ELEMENT), k = [];
|
|
330
|
+
let b = f.currentNode;
|
|
331
|
+
for (; b; )
|
|
332
|
+
b instanceof HTMLElement && b.classList.contains("qalam-render-quran") && k.push(b), b = f.nextNode();
|
|
333
|
+
for (const N of k) {
|
|
334
|
+
const I = N.dataset.copy || "", L = N.dataset.citation || "", E = document.createElement("span");
|
|
335
|
+
E.textContent = `﴿${I}﴾ [${L}]`, N.replaceWith(E);
|
|
326
336
|
}
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
document.body.removeChild(
|
|
337
|
+
const q = document.createElement("div");
|
|
338
|
+
q.appendChild(h), document.body.appendChild(q);
|
|
339
|
+
const y = q.innerText, R = q.innerHTML;
|
|
340
|
+
document.body.removeChild(q), i.clipboardData?.setData("text/plain", y), i.clipboardData?.setData("text/html", R);
|
|
331
341
|
}, []);
|
|
332
|
-
return
|
|
342
|
+
return J(() => {
|
|
333
343
|
const i = a.current;
|
|
334
344
|
if (i)
|
|
335
345
|
return i.addEventListener("copy", s), () => i.removeEventListener("copy", s);
|
|
336
|
-
}, [s]), /* @__PURE__ */ r("div", { ref: a, className: `qalam-renderer ${t ?? ""}`, dir: n, children: e.content.map((i, c) => /* @__PURE__ */ r(
|
|
346
|
+
}, [s]), /* @__PURE__ */ r("div", { ref: a, className: `qalam-renderer ${t ?? ""}`, dir: n, children: e.content.map((i, c) => /* @__PURE__ */ r(T, { node: i }, c)) });
|
|
337
347
|
}
|
|
338
348
|
export {
|
|
339
349
|
he as Q
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { validateAST as e } from "./schema/index.js";
|
|
2
2
|
import { Q as s, a as t } from "./QalamEditor-sYrI0Izl.js";
|
|
3
|
-
import { Q as f } from "./QalamRenderer-
|
|
3
|
+
import { Q as f } from "./QalamRenderer-CbbJYMLn.js";
|
|
4
4
|
import { resolveAST as d } from "./resolver/index.js";
|
|
5
5
|
import { g as Q, a as p, b as u, i as S, l as g, r as i } from "./lookup-CFbcujyG.js";
|
|
6
6
|
export {
|
package/dist/renderer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tatweel.d.ts","sourceRoot":"","sources":["../../src/renderer/tatweel.ts"],"names":[],"mappings":"AA2IA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACnC,WAAW,EAAE,MAAM,EACnB,aAAa,GAAE,MAAW,GACzB,MAAM,
|
|
1
|
+
{"version":3,"file":"tatweel.d.ts","sourceRoot":"","sources":["../../src/renderer/tatweel.ts"],"names":[],"mappings":"AA2IA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACnC,WAAW,EAAE,MAAM,EACnB,aAAa,GAAE,MAAW,GACzB,MAAM,CA6DR"}
|